Skip to content

Commit

Permalink
tests: Add a reuse flag test for the 'incus image import'
Browse files Browse the repository at this point in the history
Signed-off-by: Piotr Resztak <[email protected]>
  • Loading branch information
presztak committed Nov 28, 2024
1 parent 56498e0 commit cb8e7da
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
1 change: 1 addition & 0 deletions test/main.sh
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,7 @@ if [ "${1:-"all"}" != "cluster" ]; then
run_test test_image_auto_update "image auto-update"
run_test test_image_prefer_cached "image prefer cached"
run_test test_image_import_dir "import image from directory"
run_test test_image_import_with_reuse "import image with reuse flag"
run_test test_image_refresh "image refresh"
run_test test_image_acl "image acl"
run_test test_cloud_init "cloud-init"
Expand Down
17 changes: 17 additions & 0 deletions test/suites/image.sh
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,23 @@ test_image_import_existing_alias() {
incus image delete newimage image2
}

test_image_import_with_reuse() {
ensure_import_testimage
incus init testimage c
testimage_fingerprint="$(incus image ls -c F -f csv testimage)"
image1_fingerprint="$(incus publish c --alias image1 | awk '{print $NF;}')"
incus delete c
incus image export image1 image1.file
incus image delete image1

incus image import image1.file.tar.gz --alias testimage --reuse

[ "$(incus image ls -c F -f csv testimage)" = "${image1_fingerprint}" ]
[ "$(incus image ls -c F -f csv "${testimage_fingerprint}" | wc -l)" = "0" ]

incus image delete testimage
}

test_image_refresh() {
# shellcheck disable=2039,3043
local INCUS2_DIR INCUS2_ADDR
Expand Down

0 comments on commit cb8e7da

Please sign in to comment.