Skip to content

Commit

Permalink
Added tests for tag-less cache-from
Browse files Browse the repository at this point in the history
  • Loading branch information
toote committed Oct 17, 2022
1 parent be871aa commit 1b09131
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 0 deletions.
25 changes: 25 additions & 0 deletions tests/build.bats
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,31 @@ load '../lib/shared'
unstub docker-compose
}

@test "Build with a cache-from image with no tag" {
export BUILDKITE_BUILD_NUMBER=1
export BUILDKITE_JOB_ID=1111
export BUILDKITE_PIPELINE_SLUG=test

export BUILDKITE_PLUGIN_DOCKER_COMPOSE_BUILD_0=helloworld
export BUILDKITE_PLUGIN_DOCKER_COMPOSE_CACHE_FROM_0=helloworld:my.repository/myservice_cache
export BUILDKITE_PLUGIN_DOCKER_COMPOSE_CONFIG="tests/composefiles/docker-compose.v3.2.yml"

stub docker \
"pull my.repository/myservice_cache : echo pulled cache image"

stub docker-compose \
"-f tests/composefiles/docker-compose.v3.2.yml -p buildkite1111 -f docker-compose.buildkite-1-override.yml build --pull helloworld : echo built helloworld"

run "$PWD"/hooks/command

assert_success
assert_output --partial "pulled cache image"
assert_output --partial "- my.repository/myservice_cache"
assert_output --partial "built helloworld"
unstub docker
unstub docker-compose
}

@test "Build with several cache-from images for one service" {
export BUILDKITE_PLUGIN_DOCKER_COMPOSE_CONFIG="tests/composefiles/docker-compose.v3.2.yml"
export BUILDKITE_JOB_ID=1111
Expand Down
22 changes: 22 additions & 0 deletions tests/v2/build.bats
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,28 @@ setup_file() {
unstub docker
}

@test "Build with a cache-from image with no tag" {
export BUILDKITE_BUILD_NUMBER=1
export BUILDKITE_JOB_ID=1111
export BUILDKITE_PIPELINE_SLUG=test

export BUILDKITE_PLUGIN_DOCKER_COMPOSE_BUILD_0=helloworld
export BUILDKITE_PLUGIN_DOCKER_COMPOSE_CACHE_FROM_0=helloworld:my.repository/myservice_cache
export BUILDKITE_PLUGIN_DOCKER_COMPOSE_CONFIG="tests/composefiles/docker-compose.v3.2.yml"

stub docker \
"pull my.repository/myservice_cache : echo pulled cache image" \
"compose -f tests/composefiles/docker-compose.v3.2.yml -p buildkite1111 -f docker-compose.buildkite-1-override.yml build --pull helloworld : echo built helloworld"

run "$PWD"/hooks/command

assert_success
assert_output --partial "pulled cache image"
assert_output --partial "- my.repository/myservice_cache"
assert_output --partial "built helloworld"
unstub docker
}

@test "Build with a cache-from image with no-cache also set" {
export BUILDKITE_PLUGIN_DOCKER_COMPOSE_CONFIG="tests/composefiles/docker-compose.v3.2.yml"
export BUILDKITE_JOB_ID=1111
Expand Down

0 comments on commit 1b09131

Please sign in to comment.