ddb8fb30cc
The bats "run" helper function sets "$status", so there's no point to checking the value of "$status" when we haven't used the "run" helper to run a command, and we almost always want to be checking the value after we have used the helper. There's no need to run commands like 'sleep' or 'rm -f' with the helper, since they're not expected to fail, and if they do, it's probably indicative of a larger problem that we want to allow to cause tests to fail. Helper functions like start_crio already check "$status" when they call "run", so we don't need to check it again after they return. Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
65 lines
1.5 KiB
Bash
65 lines
1.5 KiB
Bash
#!/usr/bin/env bats
|
|
|
|
load helpers
|
|
|
|
IMAGE="alpine:latest"
|
|
|
|
function teardown() {
|
|
cleanup_test
|
|
}
|
|
|
|
@test "kpod save output flag" {
|
|
run ${KPOD_BINARY} ${KPOD_OPTIONS} pull $IMAGE
|
|
echo "$output"
|
|
[ "$status" -eq 0 ]
|
|
run ${KPOD_BINARY} ${KPOD_OPTIONS} save -o alpine.tar $IMAGE
|
|
echo "$output"
|
|
[ "$status" -eq 0 ]
|
|
run ${KPOD_BINARY} ${KPOD_OPTIONS} rmi $IMAGE
|
|
echo "$output"
|
|
[ "$status" -eq 0 ]
|
|
rm -f alpine.tar
|
|
}
|
|
|
|
@test "kpod save oci flag" {
|
|
run ${KPOD_BINARY} ${KPOD_OPTIONS} pull $IMAGE
|
|
[ "$status" -eq 0 ]
|
|
run ${KPOD_BINARY} ${KPOD_OPTIONS} save -o alpine.tar --format oci-archive $IMAGE
|
|
echo "$output"
|
|
[ "$status" -eq 0 ]
|
|
run ${KPOD_BINARY} ${KPOD_OPTIONS} rmi $IMAGE
|
|
[ "$status" -eq 0 ]
|
|
rm -f alpine.tar
|
|
}
|
|
|
|
@test "kpod save using stdout" {
|
|
run ${KPOD_BINARY} ${KPOD_OPTIONS} pull $IMAGE
|
|
echo "$output"
|
|
[ "$status" -eq 0 ]
|
|
run ${KPOD_BINARY} ${KPOD_OPTIONS} save > alpine.tar $IMAGE
|
|
echo "$output"
|
|
[ "$status" -eq 0 ]
|
|
run ${KPOD_BINARY} ${KPOD_OPTIONS} rmi $IMAGE
|
|
echo "$output"
|
|
[ "$status" -eq 0 ]
|
|
rm -f alpine.tar
|
|
}
|
|
|
|
@test "kpod save quiet flag" {
|
|
run ${KPOD_BINARY} ${KPOD_OPTIONS} pull $IMAGE
|
|
echo "$output"
|
|
[ "$status" -eq 0 ]
|
|
run ${KPOD_BINARY} ${KPOD_OPTIONS} save -q -o alpine.tar $IMAGE
|
|
echo "$output"
|
|
[ "$status" -eq 0 ]
|
|
run ${KPOD_BINARY} ${KPOD_OPTIONS} rmi $IMAGE
|
|
echo "$output"
|
|
[ "$status" -eq 0 ]
|
|
rm -f alpine.tar
|
|
}
|
|
|
|
@test "kpod save non-existent image" {
|
|
run ${KPOD_BINARY} ${KPOD_OPTIONS} save -o alpine.tar $IMAGE
|
|
echo "$output"
|
|
[ "$status" -ne 0 ]
|
|
}
|