Skip to content

Commit

Permalink
Merge pull request #231 from buildkite-plugins/toote_fix_tests
Browse files Browse the repository at this point in the history
Plugin tester update
  • Loading branch information
pzeballos authored Jan 12, 2023
2 parents 081a39f + 714dfd0 commit ddc89c2
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 3 deletions.
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
version: '2'
services:
tests:
image: buildkite/plugin-tester:v3.0.1
image: buildkite/plugin-tester:v4.0.0
volumes:
- ".:/plugin:ro"
4 changes: 2 additions & 2 deletions tests/pre-checkout.bats
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ load '/usr/local/lib/bats/load.bash'
run "$PWD"/hooks/pre-checkout

assert_success
refute_line --partial 'Skipping' # generate no output
refute_output # generate no output
}


Expand All @@ -17,7 +17,7 @@ load '/usr/local/lib/bats/load.bash'
run "$PWD"/hooks/pre-checkout

assert_success
refute_line --partial 'Skipping' # generate no output
refute_output # generate no output
}


Expand Down
32 changes: 32 additions & 0 deletions tests/windows.bats
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/usr/bin/env bats

load '/usr/local/lib/bats/load.bash'

setup() {
export BUILDKITE_PLUGIN_DOCKER_IMAGE=image:tag
export BUILDKITE_JOB_ID="1-2-3-4"
export BUILDKITE_PLUGIN_DOCKER_CLEANUP=false
export BUILDKITE_PLUGIN_DOCKER_MOUNT_BUILDKITE_AGENT=false
export BUILDKITE_COMMAND="pwd"
export OSTYPE="win" # important to define these test as windows
}

@test "Run with BUILDKITE_COMMAND" {
export BUILDKITE_COMMAND='command1 "a string"'
export BUILDKITE_AGENT_BINARY_PATH="/buildkite-agent"
unset BUILDKITE_PLUGIN_DOCKER_MOUNT_BUILDKITE_AGENT

stub cmd.exe \
"//C $'echo %CD%' : echo WIN_PATH"

stub docker \
"run -i --rm --volume \* --workdir \* --env BUILDKITE_JOB_ID --env BUILDKITE_BUILD_ID --env BUILDKITE_AGENT_ACCESS_TOKEN --volume \* --label com.buildkite.job-id=1-2-3-4 image:tag CMD.EXE /c 'command1 \"a string\"' : echo ran command in docker"

run "$PWD"/hooks/command

assert_success
assert_output --partial "ran command in docker"

unstub docker
unstub cmd.exe
}

0 comments on commit ddc89c2

Please sign in to comment.