Skip to content

Commit 6ac0ab3

Browse files
committed
Added test for mounting with Job API
1 parent bf317c6 commit 6ac0ab3

1 file changed

Lines changed: 23 additions & 0 deletions

File tree

tests/command.bats

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,29 @@ setup() {
119119
unstub buildkite-agent || true
120120
}
121121

122+
@test "Runs BUILDKITE_COMMAND with mount-buildkite-agent enabled and Job API" {
123+
export BUILDKITE_PLUGIN_DOCKER_MOUNT_BUILDKITE_AGENT=true
124+
export BUILDKITE_AGENT_JOB_API_SOCKET=/special/path
125+
export BUILDKITE_COMMAND="pwd"
126+
127+
stub docker \
128+
"run -t -i --rm --init --volume $PWD:/workdir --workdir /workdir --env BUILDKITE_JOB_ID --env BUILDKITE_BUILD_ID --env BUILDKITE_AGENT_ACCESS_TOKEN --volume \* --env BUILDKITE_AGENT_JOB_API_SOCKET --env BUILDKITE_AGENT_JOB_API_TOKEN --volume \* --label com.buildkite.job-id=1-2-3-4 image:tag /bin/sh -e -c 'pwd' : echo ran command in docker with buildkite agent mounted at \${23}"
129+
130+
# only for the command to exist
131+
stub buildkite-agent \
132+
" : exit 1"
133+
134+
run "$PWD"/hooks/command
135+
136+
assert_success
137+
refute_output --partial "🚨 Failed to find buildkite-agent"
138+
assert_output --partial "ran command in docker"
139+
assert_output --partial "/bin/buildkite-agent:/usr/bin/buildkite-agent" # check agent is mounted
140+
141+
unstub docker
142+
unstub buildkite-agent || true
143+
}
144+
122145
@test "Runs BUILDKITE_COMMAND with volumes" {
123146
export BUILDKITE_PLUGIN_DOCKER_WORKDIR=/app
124147
export BUILDKITE_PLUGIN_DOCKER_VOLUMES_0=/var/run/docker.sock:/var/run/docker.sock

0 commit comments

Comments
 (0)