Skip to content

Commit ea3f77c

Browse files
author
Nicole Lopez
committed
add test for env vars being passed to docker
1 parent b0caed5 commit ea3f77c

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

tests/command.bats

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,34 @@ load "$BATS_PATH/load.bash"
3333
unstub docker
3434
}
3535

36+
@test "can pass through optional params" {
37+
export BUILDKITE_PLUGIN_JUNIT_ANNOTATE_ARTIFACTS="junits/*.xml"
38+
export BUILDKITE_PLUGIN_JUNIT_ANNOTATE_JOB_UUID_FILE_PATTERN="custom_(*)_pattern.xml"
39+
export BUILDKITE_PLUGIN_JUNIT_ANNOTATE_FAILURE_OUTPUT="file"
40+
41+
artifacts_tmp="tests/tmp/$PWD/junit-artifacts"
42+
annotation_tmp="tests/tmp/$PWD/junit-annotation"
43+
44+
stub mktemp \
45+
"-d junit-annotate-plugin-artifacts-tmp.XXXXXXXXXX : mkdir -p $artifacts_tmp; echo $artifacts_tmp" \
46+
"-d junit-annotate-plugin-annotation-tmp.XXXXXXXXXX : mkdir -p $annotation_tmp; echo $annotation_tmp"
47+
48+
stub buildkite-agent "artifact download junits/*.xml /plugin/tests/tmp//plugin/junit-artifacts : echo Downloaded artifacts" \
49+
"annotate --context junit --style error : echo Annotation added"
50+
51+
stub docker "--log-level error run --rm --volume /plugin/tests/tmp//plugin/junit-artifacts:/junits --volume /plugin/hooks/../ruby:/src --env "BUILDKITE_PLUGIN_JUNIT_ANNOTATE_JOB_UUID_FILE_PATTERN=${BUILDKITE_PLUGIN_JUNIT_ANNOTATE_JOB_UUID_FILE_PATTERN:-}" --env "BUILDKITE_PLUGIN_JUNIT_ANNOTATE_FAILURE_OUTPUT=${BUILDKITE_PLUGIN_JUNIT_ANNOTATE_FAILURE_OUTPUT:-}" ruby:2.5-alpine /src/bin/annotate /junits : echo '<details>Failure</details>'"
52+
53+
run "$PWD/hooks/command"
54+
55+
assert_success
56+
57+
assert_output --partial "Annotation added"
58+
59+
unstub mktemp
60+
unstub buildkite-agent
61+
unstub docker
62+
}
63+
3664
@test "doesn't create annotation unless there's failures" {
3765
export BUILDKITE_PLUGIN_JUNIT_ANNOTATE_ARTIFACTS="junits/*.xml"
3866

0 commit comments

Comments
 (0)