Skip to content

Commit

Permalink
Added tests for new option
Browse files Browse the repository at this point in the history
  • Loading branch information
toote committed Nov 12, 2022
1 parent 2f9af14 commit dd9f5e8
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 0 deletions.
21 changes: 21 additions & 0 deletions tests/build.bats
Original file line number Diff line number Diff line change
Expand Up @@ -793,5 +793,26 @@ load '../lib/shared'
assert_output --partial "built myservice"
assert_output --partial "with ssh"

unstub docker-compose
}

@test "Build with secrets" {
export BUILDKITE_BUILD_NUMBER=1
export BUILDKITE_JOB_ID=1111
export BUILDKITE_PIPELINE_SLUG=test

export BUILDKITE_PLUGIN_DOCKER_COMPOSE_BUILD=myservice
export BUILDKITE_PLUGIN_DOCKER_COMPOSE_SECRETS_0='id=test,file=~/.test'
export BUILDKITE_PLUGIN_DOCKER_COMPOSE_SECRETS_1='id=SECRET_VAR'

stub docker-compose \
"-f docker-compose.yml -p buildkite1111 -f docker-compose.buildkite-1-override.yml build --pull --secret \* --secret \* \* : echo built \${13} with secrets \${10} and \${12}"

run "$PWD"/hooks/command

assert_success
assert_output --partial "built myservice"
assert_output --partial "with secrets id=test,file=~/.test and id=SECRET_VAR"

unstub docker-compose
}
22 changes: 22 additions & 0 deletions tests/v2/build.bats
Original file line number Diff line number Diff line change
Expand Up @@ -627,5 +627,27 @@ setup_file() {
assert_output --partial "built myservice"
assert_output --partial "with ssh"

unstub docker
}


@test "Build with secrets" {
export BUILDKITE_BUILD_NUMBER=1
export BUILDKITE_JOB_ID=1111
export BUILDKITE_PIPELINE_SLUG=test

export BUILDKITE_PLUGIN_DOCKER_COMPOSE_BUILD=myservice
export BUILDKITE_PLUGIN_DOCKER_COMPOSE_SECRETS_0='id=test,file=~/.test'
export BUILDKITE_PLUGIN_DOCKER_COMPOSE_SECRETS_1='id=SECRET_VAR'

stub docker \
"compose -f docker-compose.yml -p buildkite1111 -f docker-compose.buildkite-1-override.yml build --pull --secret \* --secret \* \* : echo built \${14} with secrets \${11} and \${13}"

run "$PWD"/hooks/command

assert_success
assert_output --partial "built myservice"
assert_output --partial "with secrets id=test,file=~/.test and id=SECRET_VAR"

unstub docker
}

0 comments on commit dd9f5e8

Please sign in to comment.