From fb565af0a05d0dc0c8f05159ee170146d994796a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20M=C3=ADchal?= Date: Thu, 11 Nov 2021 02:46:21 +0200 Subject: [PATCH] test/system: Add function for setting up environment Instead of typing out two function names to set up the test environment, type out only one. We never know if a new set up function will show up. https://github.com/containers/toolbox/pull/818 --- test/system/000-setup.bats | 3 +-- test/system/001-version.bats | 4 ++++ test/system/002-help.bats | 2 +- test/system/100-root.bats | 3 +-- test/system/101-create.bats | 3 +-- test/system/102-list.bats | 3 +-- test/system/103-container.bats | 3 +-- test/system/104-run.bats | 3 +-- test/system/105-enter.bats | 3 +-- test/system/106-rm.bats | 3 +-- test/system/107-rmi.bats | 3 +-- test/system/libs/helpers.bash | 5 +++++ 12 files changed, 19 insertions(+), 19 deletions(-) diff --git a/test/system/000-setup.bats b/test/system/000-setup.bats index 957f57c..8259c32 100644 --- a/test/system/000-setup.bats +++ b/test/system/000-setup.bats @@ -3,8 +3,7 @@ load 'libs/helpers' @test "test suite: Setup" { - # Setup container storage paths - setup_containers_store + _setup_environment # Cache the default image for the system _pull_and_cache_distro_image $(get_system_id) $(get_system_version) || die # Cache all images that will be needed during the tests diff --git a/test/system/001-version.bats b/test/system/001-version.bats index 499fa56..a627126 100644 --- a/test/system/001-version.bats +++ b/test/system/001-version.bats @@ -4,6 +4,10 @@ load 'libs/bats-support/load' load 'libs/bats-assert/load' load 'libs/helpers.bash' +setup() { + _setup_environment +} + @test "version: Check version using option --version" { run $TOOLBOX --version diff --git a/test/system/002-help.bats b/test/system/002-help.bats index 48d69cd..525d444 100644 --- a/test/system/002-help.bats +++ b/test/system/002-help.bats @@ -5,7 +5,7 @@ load 'libs/bats-assert/load' load 'libs/helpers.bash' setup() { - check_xdg_runtime_dir + _setup_environment } @test "help: Run command 'help'" { diff --git a/test/system/100-root.bats b/test/system/100-root.bats index 8d766cd..32d8790 100644 --- a/test/system/100-root.bats +++ b/test/system/100-root.bats @@ -5,8 +5,7 @@ load 'libs/bats-assert/load' load 'libs/helpers' setup() { - check_xdg_runtime_dir - setup_containers_store + _setup_environment cleanup_containers } diff --git a/test/system/101-create.bats b/test/system/101-create.bats index 5aaf797..0e06e3a 100644 --- a/test/system/101-create.bats +++ b/test/system/101-create.bats @@ -5,8 +5,7 @@ load 'libs/bats-assert/load' load 'libs/helpers' setup() { - check_xdg_runtime_dir - setup_containers_store + _setup_environment cleanup_containers } diff --git a/test/system/102-list.bats b/test/system/102-list.bats index da1a49d..1989409 100644 --- a/test/system/102-list.bats +++ b/test/system/102-list.bats @@ -5,8 +5,7 @@ load 'libs/bats-assert/load' load 'libs/helpers' setup() { - check_xdg_runtime_dir - setup_containers_store + _setup_environment cleanup_all } diff --git a/test/system/103-container.bats b/test/system/103-container.bats index 795d4c1..1ed8fe2 100644 --- a/test/system/103-container.bats +++ b/test/system/103-container.bats @@ -5,8 +5,7 @@ load 'libs/bats-assert/load' load 'libs/helpers' setup() { - check_xdg_runtime_dir - setup_containers_store + _setup_environment cleanup_containers } diff --git a/test/system/104-run.bats b/test/system/104-run.bats index 0ff0e06..e4574a6 100644 --- a/test/system/104-run.bats +++ b/test/system/104-run.bats @@ -5,8 +5,7 @@ load 'libs/bats-assert/load' load 'libs/helpers' setup() { - check_xdg_runtime_dir - setup_containers_store + _setup_environment cleanup_containers } diff --git a/test/system/105-enter.bats b/test/system/105-enter.bats index 5084439..82f5c83 100644 --- a/test/system/105-enter.bats +++ b/test/system/105-enter.bats @@ -5,8 +5,7 @@ load 'libs/bats-assert/load' load 'libs/helpers' setup() { - check_xdg_runtime_dir - setup_containers_store + _setup_environment cleanup_containers } diff --git a/test/system/106-rm.bats b/test/system/106-rm.bats index bcafee2..e9ac44c 100644 --- a/test/system/106-rm.bats +++ b/test/system/106-rm.bats @@ -5,8 +5,7 @@ load 'libs/bats-assert/load' load 'libs/helpers' setup() { - check_xdg_runtime_dir - setup_containers_store + _setup_environment cleanup_containers } diff --git a/test/system/107-rmi.bats b/test/system/107-rmi.bats index 1af9cfe..6518c27 100644 --- a/test/system/107-rmi.bats +++ b/test/system/107-rmi.bats @@ -5,8 +5,7 @@ load 'libs/bats-assert/load' load 'libs/helpers' setup() { - check_xdg_runtime_dir - setup_containers_store + _setup_environment cleanup_all } diff --git a/test/system/libs/helpers.bash b/test/system/libs/helpers.bash index b12e401..92dfe5b 100644 --- a/test/system/libs/helpers.bash +++ b/test/system/libs/helpers.bash @@ -31,6 +31,11 @@ function cleanup_containers() { } +function _setup_environment() { + _setup_containers_store + check_xdg_runtime_dir +} + function _setup_containers_store() { mkdir -p ${TEMP_STORAGE_DIR} # Setup a storage config file for PODMAN