Skip to content

Commit 2838380

Browse files
committed
Add a BATS test too
1 parent 051eb3c commit 2838380

File tree

2 files changed

+29
-4
lines changed

2 files changed

+29
-4
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/tests/tmp

tests/command.bats

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,33 @@
22

33
load "$BATS_PATH/load.bash"
44

5-
@test "calls git log" {
6-
stub git "log : echo some-log"
7-
git log
5+
# Uncomment to get debug output from each stub
6+
# export MKTEMP_STUB_DEBUG=/dev/tty
7+
# export BUILDKITE_AGENT_STUB_DEBUG=/dev/tty
8+
# export DOCKER_STUB_DEBUG=/dev/tty
9+
10+
@test "runs the annotator and creates the annotation" {
11+
export BUILDKITE_PLUGIN_JUNIT_ANNOTATE_ARTIFACTS="junits/*.xml"
12+
13+
artifacts_tmp="tests/tmp/$PWD/junit-artifacts"
14+
annotation_tmp="tests/tmp/$PWD/junit-annotation"
15+
16+
stub mktemp \
17+
"-d junit-annotate-plugin-artifacts-tmp.XXXXXXXXXX : mkdir -p $artifacts_tmp; echo $artifacts_tmp" \
18+
"-d junit-annotate-plugin-annotation-tmp.XXXXXXXXXX : mkdir -p $annotation_tmp; echo $annotation_tmp"
19+
20+
stub buildkite-agent "artifact download junits/*.xml /plugin/tests/tmp//plugin/junit-artifacts : echo Downloaded artifacts" \
21+
"annotate --context junit --style error : echo Annotation added"
22+
23+
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= ruby:2.5-alpine /src/bin/annotate /junits : echo ANNOTATION"
24+
25+
run "$PWD/hooks/command"
26+
827
assert_success
9-
unstub git
28+
29+
assert_output --partial "Annotation added"
30+
31+
unstub mktemp
32+
unstub buildkite-agent
33+
unstub docker
1034
}

0 commit comments

Comments
 (0)