Skip to content

Commit 4814a21

Browse files
committed
tests: Add a reuse flag test for the 'incus image import'
Signed-off-by: Piotr Resztak <[email protected]>
1 parent 0094a40 commit 4814a21

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

test/main.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,7 @@ if [ "${1:-"all"}" != "cluster" ]; then
296296
run_test test_image_auto_update "image auto-update"
297297
run_test test_image_prefer_cached "image prefer cached"
298298
run_test test_image_import_dir "import image from directory"
299+
run_test test_image_import_with_reuse "import image with reuse flag"
299300
run_test test_image_refresh "image refresh"
300301
run_test test_image_acl "image acl"
301302
run_test test_cloud_init "cloud-init"

test/suites/image.sh

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,22 @@ test_image_import_existing_alias() {
122122
incus image delete newimage image2
123123
}
124124

125+
test_image_import_with_reuse() {
126+
ensure_import_testimage
127+
incus init testimage c
128+
fingerprint="$(incus publish c --alias image1 | awk '{print $NF;}')"
129+
incus delete c
130+
incus image export image1 image1.file
131+
incus image delete image1
132+
133+
incus image import image1.file.tar.gz --alias testimage --reuse
134+
135+
[ "$(incus image ls -c F -f csv testimage)" = "${fingerprint}" ]
136+
[ "$(incus image ls -f csv | wc -l)" = "1" ]
137+
138+
incus image delete testimage
139+
}
140+
125141
test_image_refresh() {
126142
# shellcheck disable=2039,3043
127143
local INCUS2_DIR INCUS2_ADDR

0 commit comments

Comments
 (0)