From a61da78628b59704739c546521057877c69f601c Mon Sep 17 00:00:00 2001 From: Oliver Gutierrez Date: Tue, 14 Sep 2021 13:41:17 +0100 Subject: [PATCH] Tests fixes for gating diff --git a/test/system/002-help.bats b/test/system/002-help.bats index 4ff02c6..cca3da4 100644 --- a/test/system/002-help.bats +++ b/test/system/002-help.bats @@ -4,6 +4,10 @@ load 'libs/bats-support/load' load 'libs/bats-assert/load' load 'libs/helpers.bash' +setup() { + check_xdg_runtime_dir +} + @test "help: Run command 'help'" { run $TOOLBOX help diff --git a/test/system/101-create.bats b/test/system/101-create.bats index 3cc3eaf..937342a 100644 --- a/test/system/101-create.bats +++ b/test/system/101-create.bats @@ -5,6 +5,7 @@ load 'libs/bats-assert/load' load 'libs/helpers' setup() { + check_xdg_runtime_dir cleanup_containers } @@ -13,7 +14,7 @@ teardown() { } -@test "create: Create the default container" { +@test "create: Create the default container ($(get_system_id)-$(get_system_version))" { pull_default_image run $TOOLBOX -y create @@ -62,7 +63,7 @@ teardown() { assert_success assert_output --partial "Created container: fedora-toolbox-32" - assert_output --partial "Enter with: toolbox enter fedora-toolbox-32" + assert_output --partial "Enter with: toolbox enter --release 32" # Make sure the container has actually been created run podman ps -a diff --git a/test/system/102-list.bats b/test/system/102-list.bats index 184ad6c..770e8d2 100644 --- a/test/system/102-list.bats +++ b/test/system/102-list.bats @@ -5,6 +5,7 @@ load 'libs/bats-assert/load' load 'libs/helpers' setup() { + check_xdg_runtime_dir cleanup_all } diff --git a/test/system/104-run.bats b/test/system/104-run.bats index 026126b..03cf291 100644 --- a/test/system/104-run.bats +++ b/test/system/104-run.bats @@ -5,6 +5,7 @@ load 'libs/bats-assert/load' load 'libs/helpers' setup() { + check_xdg_runtime_dir cleanup_containers } diff --git a/test/system/105-rm.bats b/test/system/105-rm.bats index 9f1435b..68e3c03 100644 --- a/test/system/105-rm.bats +++ b/test/system/105-rm.bats @@ -5,6 +5,7 @@ load 'libs/bats-assert/load' load 'libs/helpers' setup() { + check_xdg_runtime_dir cleanup_containers } diff --git a/test/system/106-rmi.bats b/test/system/106-rmi.bats index 0ef0ebe..b48f802 100644 --- a/test/system/106-rmi.bats +++ b/test/system/106-rmi.bats @@ -5,6 +5,7 @@ load 'libs/bats-assert/load' load 'libs/helpers' setup() { + check_xdg_runtime_dir cleanup_all } diff --git a/test/system/libs/helpers.bash b/test/system/libs/helpers.bash index d59d661..3d465d3 100644 --- a/test/system/libs/helpers.bash +++ b/test/system/libs/helpers.bash @@ -8,11 +8,10 @@ readonly TOOLBOX=${TOOLBOX:-toolbox} readonly SKOPEO=$(command -v skopeo) # Helpful globals -readonly PROJECT_DIR=${PWD} -readonly IMAGE_CACHE_DIR="${PROJECT_DIR}/image-cache" +readonly IMAGE_CACHE_DIR="${BATS_RUN_TMPDIR}/image-cache" # Images -declare -Ag IMAGES=([busybox]="docker.io/library/busybox" \ +declare -Ag IMAGES=([busybox]="quay.io/toolbox_tests/busybox" \ [fedora]="registry.fedoraproject.org/fedora-toolbox" \ [rhel]="registry.access.redhat.com/ubi8") @@ -245,6 +244,7 @@ function find_os_release() { # Returns the content of field ID in os-release function get_system_id() { + if [[ -z ${TOOLBOX_TEST_SYSTEM_ID} ]]; then local os_release os_release="$(find_os_release)" @@ -255,19 +255,34 @@ function get_system_id() { fi echo $(awk -F= '/ID/ {print $2}' $os_release | head -n 1) + else + echo ${TOOLBOX_TEST_SYSTEM_ID} + fi } # Returns the content of field VERSION_ID in os-release function get_system_version() { - local os_release + if [[ -z ${TOOLBOX_TEST_VERSION_ID} ]]; then + local os_release - os_release="$(find_os_release)" + os_release="$(find_os_release)" - if [[ -z "$os_release" ]]; then - echo "" - return + if [[ -z "$os_release" ]]; then + echo "" + return + fi + + echo $(awk -F= '/VERSION_ID/ {print $2}' $os_release | head -n 1) + else + echo ${TOOLBOX_TEST_VERSION_ID} fi +} - echo $(awk -F= '/VERSION_ID/ {print $2}' $os_release | head -n 1) + +# Setup the XDG_RUNTIME_DIR variable if not set +function check_xdg_runtime_dir() { + if [[ -z "${XDG_RUNTIME_DIR}" ]]; then + export XDG_RUNTIME_DIR="/run/user/${UID}" + fi } -- 2.31.1