kpod.bats: correct syntax errors

Correct some syntax errors in kpod.bats, ensure that it always checks
the exit status of "kpod rmi" commands, correct the order of options
when calling "kpod inspect", and test for string equality correctly.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
This commit is contained in:
Nalin Dahyabhai 2017-08-17 12:45:08 -04:00
parent ef8df00e6a
commit 178c1e9ccb

View file

@ -198,8 +198,9 @@ function teardown() {
run bash -c "${KPOD_BINARY} $KPOD_OPTIONS inspect redis:alpine | python -m json.tool" run bash -c "${KPOD_BINARY} $KPOD_OPTIONS inspect redis:alpine | python -m json.tool"
echo "$output" echo "$output"
[ "$status" -eq 0 ] [ "$status" -eq 0 ]
}
run ${KPOD_BINARY} $KPOD_OPTIONS rmi redis:alpine run ${KPOD_BINARY} $KPOD_OPTIONS rmi redis:alpine
[ "$status" -eq 0 ]
}
@test "kpod inspect non-existent container" { @test "kpod inspect non-existent container" {
@ -211,13 +212,14 @@ function teardown() {
@test "kpod inspect with format" { @test "kpod inspect with format" {
run ${KPOD_BINARY} $KPOD_OPTIONS pull redis:alpine run ${KPOD_BINARY} $KPOD_OPTIONS pull redis:alpine
[ "$status" -eq 0 ] [ "$status" -eq 0 ]
run ${KPOD_BINARY} $KPOD_OPTIONS --format {{.ID}} inspect redis:alpine run ${KPOD_BINARY} $KPOD_OPTIONS inspect --format {{.ID}} redis:alpine
[ "$status" -eq 0] [ "$status" -eq 0 ]
inspectOutput="$output" inspectOutput="$output"
run ${KPOD_BINARY} $KPOD_OPTIONS images --quiet redis:alpine run ${KPOD_BINARY} $KPOD_OPTIONS images --quiet redis:alpine
[ "$status" -eq 0] [ "$status" -eq 0 ]
[ "$output" -eq "$inspectOutput" ] [ "$output" = "$inspectOutput" ]
run ${KPOD_BINARY} $KPOD_OPTIONS rmi redis:alpine run ${KPOD_BINARY} $KPOD_OPTIONS rmi redis:alpine
[ "$status" -eq 0 ]
} }
@test "kpod inspect specified type" { @test "kpod inspect specified type" {
@ -225,8 +227,9 @@ function teardown() {
[ "$status" -eq 0 ] [ "$status" -eq 0 ]
run bash -c "${KPOD_BINARY} $KPOD_OPTIONS inspect --type image redis:alpine | python -m json.tool" run bash -c "${KPOD_BINARY} $KPOD_OPTIONS inspect --type image redis:alpine | python -m json.tool"
echo "$output" echo "$output"
[ "$status" -eq 0] [ "$status" -eq 0 ]
run ${KPOD_BINARY} $KPOD_OPTIONS rmi redis:alpine run ${KPOD_BINARY} $KPOD_OPTIONS rmi redis:alpine
[ "$status" -eq 0 ]
} }
@test "kpod images" { @test "kpod images" {
@ -245,6 +248,7 @@ function teardown() {
@test "kpod images check name json output" { @test "kpod images check name json output" {
run ${KPOD_BINARY} $KPOD_OPTIONS pull debian:6.0.10 run ${KPOD_BINARY} $KPOD_OPTIONS pull debian:6.0.10
run ${KPOD_BINARY} $KPOD_OPTIONS images --format json run ${KPOD_BINARY} $KPOD_OPTIONS images --format json
echo "$output"
name=$(echo $output | python -c 'import sys; import json; print(json.loads(sys.stdin.read())[0])["names"][0]') name=$(echo $output | python -c 'import sys; import json; print(json.loads(sys.stdin.read())[0])["names"][0]')
[ "$name" == "docker.io/library/debian:6.0.10" ] [ "$name" = "docker.io/library/debian:6.0.10" ]
} }