Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Justfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ test:
bats tests/test_ujust.bats
bats tests/test_ublue_fastfetch.bats
bats tests/test_motd_integration.bats
bats tests/test_clean_system_podman_path.bats
bats tests/test_ublue_image_info.bats
bats tests/test_profile_d.bats
bats tests/test_dynamic_wallpaper.bats
Expand Down
8 changes: 4 additions & 4 deletions system_files/shared/usr/share/ublue-os/just/default.just
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@ clean-system:
#!/usr/bin/bash
if gum confirm "Prune all Podman images and volumes?"; then
echo "Images that would be pruned:"
podman image ls --filter dangling=true --format "{{{{.Repository}}}}:{{{{.Tag}}}} {{{{.ID}}}}" 2>/dev/null | head -20
/usr/bin/podman image ls --filter dangling=true --format "{{{{.Repository}}}}:{{{{.Tag}}}} {{{{.ID}}}}" 2>/dev/null | head -20
echo "Volumes that would be pruned:"
podman volume ls --filter dangling=true --quiet 2>/dev/null | head -20
/usr/bin/podman volume ls --filter dangling=true --quiet 2>/dev/null | head -20
if gum confirm "Proceed with pruning Podman images and volumes?"; then
podman image prune -af
podman volume prune -f
/usr/bin/podman image prune -af
/usr/bin/podman volume prune -f
fi
fi

Expand Down
33 changes: 33 additions & 0 deletions tests/test_clean_system_podman_path.bats
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#!/usr/bin/env bats

DEFAULT_JUST="${BATS_TEST_DIRNAME}/../system_files/shared/usr/share/ublue-os/just/default.just"

_clean_system_recipe() {
awk '
/^clean-system:/ { in_recipe=1; next }
in_recipe && $0 !~ /^ / && $0 !~ /^$/ { exit }
in_recipe && $0 ~ /^ / { print }
' "${DEFAULT_JUST}"
}

@test "clean-system: uses OS-managed Podman binary" {
local recipe
recipe="$(_clean_system_recipe)"

run grep -Fq "/usr/bin/podman image ls" <<< "${recipe}"
[ "${status}" -eq 0 ]
run grep -Fq "/usr/bin/podman volume ls" <<< "${recipe}"
[ "${status}" -eq 0 ]
run grep -Fq "/usr/bin/podman image prune -af" <<< "${recipe}"
[ "${status}" -eq 0 ]
run grep -Fq "/usr/bin/podman volume prune -f" <<< "${recipe}"
[ "${status}" -eq 0 ]
}

@test "clean-system: does not use unqualified podman" {
local recipe
recipe="$(_clean_system_recipe)"

run grep -Eq '(^|[[:space:]])podman[[:space:]]' <<< "${recipe}"
[ "${status}" -ne 0 ]
}
Loading