From 211da9018b3e213589cda82cd56f0df713625b36 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mat=C3=ADas=20A=2E=20Bellone?= Date: Tue, 13 Dec 2022 03:42:49 -0300 Subject: [PATCH] Added v2 tests --- tests/v2/push.bats | 30 ++++++++++++++++++++++++++++++ tests/v2/run.bats | 28 ++++++++++++++++++++++++++++ 2 files changed, 58 insertions(+) diff --git a/tests/v2/push.bats b/tests/v2/push.bats index d0ef5ae1..f6d109af 100644 --- a/tests/v2/push.bats +++ b/tests/v2/push.bats @@ -96,6 +96,36 @@ setup_file() { unstub buildkite-agent } +@test "Push a prebuilt image with a repository and a tag in compatibility mode" { + export BUILDKITE_BUILD_NUMBER=1 + export BUILDKITE_JOB_ID=1111 + export BUILDKITE_PIPELINE_SLUG=test + + export BUILDKITE_PLUGIN_DOCKER_COMPOSE_PUSH=myservice:my.repository/myservice:llamas + export BUILDKITE_PLUGIN_DOCKER_COMPOSE_COMPATIBILITY=true + + stub docker \ + "compose --compatibility -f docker-compose.yml -p buildkite1111 config : echo blah" \ + "pull myimage : echo pulled prebuilt image" \ + "tag myimage buildkite1111_myservice : echo " \ + "tag buildkite1111_myservice my.repository/myservice:llamas : echo tagged image" \ + "push my.repository/myservice:llamas : echo pushed myservice" + + + stub buildkite-agent \ + "meta-data exists docker-compose-plugin-built-image-tag-myservice : exit 0" \ + "meta-data get docker-compose-plugin-built-image-tag-myservice : echo myimage" + + run $PWD/hooks/command + + assert_success + assert_output --partial "pulled prebuilt image" + assert_output --partial "tagged image" + assert_output --partial "pushed myservice" + unstub docker + unstub buildkite-agent +} + @test "Push a prebuilt image with an invalid tag" { export BUILDKITE_JOB_ID=1111 export BUILDKITE_PLUGIN_DOCKER_COMPOSE_PUSH=myservice:my.repository/myservice:-llamas diff --git a/tests/v2/run.bats b/tests/v2/run.bats index 711019df..58fc252e 100644 --- a/tests/v2/run.bats +++ b/tests/v2/run.bats @@ -586,6 +586,34 @@ export BUILDKITE_JOB_ID=1111 unstub buildkite-agent } + +@test "Run with compatibility mode" { + export BUILDKITE_BUILD_NUMBER=1 + export BUILDKITE_COMMAND=pwd + export BUILDKITE_JOB_ID=1111 + export BUILDKITE_PIPELINE_SLUG=test + + export BUILDKITE_PLUGIN_DOCKER_COMPOSE_RUN=myservice + export BUILDKITE_PLUGIN_DOCKER_COMPOSE_CLEANUP=false + export BUILDKITE_PLUGIN_DOCKER_COMPOSE_COMPATIBILITY=true + + stub docker \ + "compose --compatibility -f docker-compose.yml -p buildkite1111 -f docker-compose.buildkite-1-override.yml pull myservice : echo pulled myservice" \ + "compose --compatibility -f docker-compose.yml -p buildkite1111 -f docker-compose.buildkite-1-override.yml up -d --scale myservice=0 myservice : echo started dependencies for myservice" \ + "compose --compatibility -f docker-compose.yml -p buildkite1111 -f docker-compose.buildkite-1-override.yml run --name buildkite1111_myservice_build_1 --rm myservice /bin/sh -e -c 'pwd' : echo ran myservice with use aliases output" + + stub buildkite-agent \ + "meta-data exists docker-compose-plugin-built-image-tag-myservice : exit 0" \ + "meta-data get docker-compose-plugin-built-image-tag-myservice : echo myimage" + + run "$PWD"/hooks/command + + assert_success + assert_output --partial "ran myservice with use aliases output" + unstub docker + unstub buildkite-agent +} + @test "Run with a volumes option" { export BUILDKITE_JOB_ID=1111 export BUILDKITE_PLUGIN_DOCKER_COMPOSE_RUN=myservice