Skip to content

Commit a9765ea

Browse files
committed
Add tests
1 parent 22e50a3 commit a9765ea

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

tests/command.bats

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ load "$BATS_PATH/load.bash"
66
# export MKTEMP_STUB_DEBUG=/dev/tty
77
# export BUILDKITE_AGENT_STUB_DEBUG=/dev/tty
88
# export DOCKER_STUB_DEBUG=/dev/tty
9+
# export DU_STUB_DEBUG=/dev/tty
910

1011
@test "runs the annotator and creates the annotation" {
1112
export BUILDKITE_PLUGIN_JUNIT_ANNOTATE_ARTIFACTS="junits/*.xml"
@@ -118,3 +119,32 @@ load "$BATS_PATH/load.bash"
118119

119120
assert_output --partial "BUILDKITE_PLUGIN_JUNIT_ANNOTATE_ARTIFACTS: unbound variable"
120121
}
122+
123+
@test "fails if the annotation is larger than " {
124+
export BUILDKITE_PLUGIN_JUNIT_ANNOTATE_ARTIFACTS="junits/*.xml"
125+
126+
artifacts_tmp="tests/tmp/$PWD/junit-artifacts"
127+
annotation_tmp="tests/tmp/$PWD/junit-annotation"
128+
129+
stub mktemp \
130+
"-d junit-annotate-plugin-artifacts-tmp.XXXXXXXXXX : mkdir -p $artifacts_tmp; echo $artifacts_tmp" \
131+
"-d junit-annotate-plugin-annotation-tmp.XXXXXXXXXX : mkdir -p $annotation_tmp; echo $annotation_tmp"
132+
133+
# 1kb over the 100k size limit of annotations
134+
stub du "-k /plugin/tests/tmp//plugin/junit-annotation/annotation.md : echo 101 /plugin/tests/tmp//plugin/junit-annotation/annotation.md"
135+
136+
stub buildkite-agent "artifact download junits/*.xml /plugin/tests/tmp//plugin/junit-artifacts : echo Downloaded artifacts"
137+
138+
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= --env BUILDKITE_PLUGIN_JUNIT_ANNOTATE_FAILURE_FORMAT= ruby:2.5-alpine /src/bin/annotate /junits : echo '<details>Failure</details>'"
139+
140+
run "$PWD/hooks/command"
141+
142+
assert_success
143+
144+
assert_output --partial "Failures too large to annotate"
145+
146+
unstub docker
147+
unstub buildkite-agent
148+
unstub du
149+
unstub mktemp
150+
}

0 commit comments

Comments
 (0)