11#! /usr/bin/env bats
22
3- load ' /usr/local/lib/bats/load.bash'
4-
53# Uncomment the following to get more detail on failures of stubs
64# export DOCKER_STUB_DEBUG=/dev/tty
75
8- @test " Runs the linter via Docker" {
6+ setup () {
7+ load " ${BATS_PLUGIN_PATH} /load.bash"
8+
99 export BUILDKITE_PLUGIN_PLUGIN_LINTER_ID=my-plugin
10+ # defining specific version to make all the tests not dependent on default
11+ export BUILDKITE_PLUGIN_PLUGIN_LINTER_IMAGE_VERSION=' latest'
12+ }
13+
14+ @test " Missing id parameter is a failure" {
15+ unset BUILDKITE_PLUGIN_PLUGIN_LINTER_ID
16+
17+ run " $PWD " /hooks/command
1018
19+ assert_failure
20+ assert_output --partial ' Missing id parameter in plugin configuration'
21+ }
22+
23+ @test " Runs the linter via Docker" {
1124 stub docker \
1225 " pull buildkite/plugin-linter : echo pulled image" \
13- " run -it --rm --volume /plugin:/plugin:ro --env PLUGIN_ID=my-plugin buildkite/plugin-linter : echo linted"
26+ " run -it --rm --volume /plugin:/plugin:ro --env PLUGIN_ID=my-plugin buildkite/plugin-linter:latest : echo linted"
1427
15- run $PWD /hooks/command
28+ run " $PWD " /hooks/command
1629
1730 assert_success
1831 assert_output --partial " pulled image"
@@ -21,14 +34,28 @@ load '/usr/local/lib/bats/load.bash'
2134}
2235
2336@test " Supports the readme option" {
24- export BUILDKITE_PLUGIN_PLUGIN_LINTER_ID=my-plugin
2537 export BUILDKITE_PLUGIN_PLUGIN_LINTER_README=some-readme.yml
2638
2739 stub docker \
2840 " pull buildkite/plugin-linter : echo pulled image" \
29- " run -it --rm --volume /plugin:/plugin:ro --env PLUGIN_ID=my-plugin --env PLUGIN_README=some-readme.yml buildkite/plugin-linter : echo linted"
41+ " run -it --rm --volume /plugin:/plugin:ro --env PLUGIN_ID=my-plugin --env PLUGIN_README=some-readme.yml buildkite/plugin-linter:latest : echo linted"
42+
43+ run " $PWD " /hooks/command
44+
45+ assert_success
46+ assert_output --partial " pulled image"
47+ assert_output --partial " linted"
48+ unstub docker
49+ }
50+
51+ @test " Support not specifying a tag" {
52+ unset BUILDKITE_PLUGIN_PLUGIN_LINTER_IMAGE_VERSION
53+
54+ stub docker \
55+ " pull buildkite/plugin-linter : echo pulled image" \
56+ " run -it --rm --volume /plugin:/plugin:ro --env PLUGIN_ID=my-plugin buildkite/plugin-linter:v2.0.1 : echo linted"
3057
31- run $PWD /hooks/command
58+ run " $PWD " /hooks/command
3259
3360 assert_success
3461 assert_output --partial " pulled image"
0 commit comments