docs/test/integration/api/save.bats

45 lines
966 B
Bash

#!/usr/bin/env bats
load ../helpers
function teardown() {
swarm_manage_cleanup
stop_docker
}
@test "docker save" {
# Start one empty host and one with busybox to ensure swarm selects the
# right one (and not one at random).
start_docker 1
start_docker_with_busybox 1
swarm_manage
# make sure busybox image exists
run docker_swarm images
[ "$status" -eq 0 ]
[[ "${output}" == *"busybox"* ]]
temp_file_name=$(mktemp)
temp_file_name_o=$(mktemp)
# save >, image->tar
docker_swarm save busybox > $temp_file_name
# save -o, image->tar
docker_swarm save -o $temp_file_name_o busybox
# saved image file exists, not empty and is tar file
[ -s $temp_file_name ]
run file $temp_file_name
[ "$status" -eq 0 ]
[[ "${output}" == *"tar archive"* ]]
[ -s $temp_file_name_o ]
run file $temp_file_name_o
[ "$status" -eq 0 ]
[[ "${output}" == *"tar archive"* ]]
# after ok, delete saved tar file
rm -f $temp_file_name
rm -f $temp_file_name_o
}