cri-o/test/kpod_images.bats
Nalin Dahyabhai ddb8fb30cc Correct our usage of the bats run helper
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>
2017-10-12 17:54:47 -04:00

47 lines
1.2 KiB
Bash

#!/usr/bin/env bats
load helpers
IMAGE="debian:6.0.10"
function teardown() {
cleanup_test
}
@test "kpod images" {
run ${KPOD_BINARY} ${KPOD_OPTIONS} pull ${IMAGE}
echo "$output"
[ "$status" -eq 0 ]
run ${KPOD_BINARY} ${KPOD_OPTIONS} images
echo "$output"
[ "$status" -eq 0 ]
run ${KPOD_BINARY} ${KPOD_OPTIONS} rmi ${IMAGE}
echo "$output"
[ "$status" -eq 0 ]
}
@test "kpod images test valid json" {
run ${KPOD_BINARY} ${KPOD_OPTIONS} pull ${IMAGE}
echo "$output"
[ "$status" -eq 0 ]
run ${KPOD_BINARY} ${KPOD_OPTIONS} images --format json
echo "$output" | python -m json.tool
[ "$status" -eq 0 ]
run ${KPOD_BINARY} ${KPOD_OPTIONS} rmi ${IMAGE}
echo "$output"
[ "$status" -eq 0 ]
}
@test "kpod images check name json output" {
run ${KPOD_BINARY} ${KPOD_OPTIONS} pull ${IMAGE}
echo "$output"
[ "$status" -eq 0 ]
run ${KPOD_BINARY} ${KPOD_OPTIONS} images --format json
echo "$output"
[ "$status" -eq 0 ]
name=$(echo $output | python -c 'import sys; import json; print(json.loads(sys.stdin.read())[0])["names"][0]')
[ "$name" = "docker.io/library/${IMAGE}" ]
run ${KPOD_BINARY} ${KPOD_OPTIONS} rmi ${IMAGE}
echo "$output"
[ "$status" -eq 0 ]
}