test/reload_image.bats: nits
1. Ditch expect_pull_image, can be replaced by one-liner.
2. Make sure to create directory for CONTAINER_REGISTRIES_CONF
3. Move start_crio to setup
4. No need to export TEST_IMAGE
@@ -5,10 +5,12 @@ load helpers
function setup() {
setup_test
- export TEST_IMAGE=quay.io/saschagrunert/hello-world \
- CONTAINER_REGISTRIES_CONF="$TESTDIR/containers/registries.conf"
+ TEST_IMAGE=quay.io/saschagrunert/hello-world
+ export CONTAINER_REGISTRIES_CONF="$TESTDIR/containers/registries.conf"
+ mkdir "$TESTDIR/containers"
printf "[[registry]]\nlocation = 'quay.io/saschagrunert'\nblocked = true" \
>> "$CONTAINER_REGISTRIES_CONF"
+ start_crio
}
function teardown() {
@@ -23,15 +25,8 @@ function expect_log_failure() {
wait_for_log "system registries reload failed"
}
-function expect_pull_image() {
- run crictl pull "$TEST_IMAGE"
- echo "$output"
- [ "$status" -eq "$1" ]
-}
-
@test "reload system registries should succeed" {
# given
- start_crio
replace_config "log_level" "debug"
# when
@@ -39,12 +34,11 @@ function expect_pull_image() {
# then
expect_log_success
- expect_pull_image 1
+ ! crictl pull "$TEST_IMAGE"
}
@test "reload system registries should succeed with new registry" {
# given
- start_crio
replace_config "log_level" "debug"
sed -i 's;true;false;g' "$CONTAINER_REGISTRIES_CONF"
@@ -53,12 +47,11 @@ function expect_pull_image() {
# then
expect_log_success
- expect_pull_image 0
+ crictl pull "$TEST_IMAGE"
}
@test "reload system registries should fail on invalid syntax in file" {
# given
- start_crio
echo invalid >> "$CONTAINER_REGISTRIES_CONF"
# when
