From a9166f6f905fd17bbad2a5b44350e1bcae724e98 Mon Sep 17 00:00:00 2001 From: Adar Nimrod <nimrod@shore.co.il> Date: Sat, 30 Jan 2021 02:50:15 +0200 Subject: [PATCH] Split tests to avoid duplicate names. --- tests/root.bats | 19 +++++++++++++++++++ tests/{test.bats => user.bats} | 14 -------------- 2 files changed, 19 insertions(+), 14 deletions(-) create mode 100644 tests/root.bats rename tests/{test.bats => user.bats} (56%) diff --git a/tests/root.bats b/tests/root.bats new file mode 100644 index 0000000..0b2d949 --- /dev/null +++ b/tests/root.bats @@ -0,0 +1,19 @@ +_test_root () { + name="${1:-$BATS_TEST_DESCRIPTION}" + tag="${2:-latest}" + docker build -t "runas-$name" --build-arg "image=$name:$tag" ./ + docker run --rm -v "$BATS_TEST_DIRNAME:/data" "runas-$name" touch "$name.root" + test "$(id -u)" = "$(stat -c '%u' $name.root)" + test "$(id -g)" = "$(stat -c '%g' $name.root)" +} + +teardown () { + docker image ls --format '{{.ID}}' runas-* | xargs -r docker image rm + rm -f *.touch +} + +@test "ubuntu" { _test_root buildpack-deps bionic; } +@test "debian" { _test_root buildpack-deps stretch; } +@test "centos" { _test_root; } +@test "fedora" { _test_root; } +@test "alpine" { _test_root; } diff --git a/tests/test.bats b/tests/user.bats similarity index 56% rename from tests/test.bats rename to tests/user.bats index 70ceaa9..cf18dc1 100644 --- a/tests/test.bats +++ b/tests/user.bats @@ -1,12 +1,3 @@ -_test_root () { - name="${1:-$BATS_TEST_DESCRIPTION}" - tag="${2:-latest}" - docker build -t "runas-$name" --build-arg "image=$name:$tag" ./ - docker run --rm -v "$BATS_TEST_DIRNAME:/data" "runas-$name" touch "$name.root" - test "$(id -u)" = "$(stat -c '%u' $name.root)" - test "$(id -g)" = "$(stat -c '%g' $name.root)" -} - _test_user () { name="${1:-$BATS_TEST_DESCRIPTION}" tag="${2:-latest}" @@ -23,11 +14,6 @@ teardown () { rm -f *.touch } -@test "ubuntu" { _test_root buildpack-deps bionic; } -@test "debian" { _test_root buildpack-deps stretch; } -@test "centos" { _test_root; } -@test "fedora" { _test_root; } -@test "alpine" { _test_root; } @test "ubuntu" { _test_user buildpack-deps bionic; } @test "debian" { _test_user buildpack-deps stretch; } @test "centos" { _test_user; } -- GitLab