Skip to content

Commit fe1d4b5

Browse files
committed
Add tests for new config
1 parent 353b115 commit fe1d4b5

3 files changed

Lines changed: 49 additions & 0 deletions

File tree

README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,14 @@ Which shell check image to use.
5555

5656
Default: `koalaman/shellcheck`
5757

58+
## Developing
59+
60+
To run the tests:
61+
62+
```bash
63+
docker-compose run --rm tests bats tests
64+
```
65+
5866
## License
5967

6068
MIT (see [LICENSE](LICENSE))

compose.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
services:
2+
tests:
3+
image: buildkite/plugin-tester:v4.1.1
4+
volumes:
5+
- ".:/plugin"

tests/run.bats

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,3 +189,39 @@ load "${BATS_PLUGIN_PATH}/load.bash"
189189

190190
unstub docker
191191
}
192+
193+
@test "Shellcheck uses default image when not specified" {
194+
export BUILDKITE_PLUGIN_SHELLCHECK_FILES_0="tests/testdata/test.sh"
195+
unset BUILDKITE_PLUGIN_SHELLCHECK_IMAGE
196+
unset BUILDKITE_PLUGIN_SHELLCHECK_VERSION
197+
198+
stub docker \
199+
"run --rm -v $PWD:/mnt --workdir /mnt koalaman/shellcheck:stable --color=always tests/testdata/test.sh : echo running shellcheck on test.sh"
200+
201+
run "$PWD/hooks/command"
202+
203+
assert_success
204+
assert_output --partial "Running shellcheck on 1 files"
205+
assert_output --partial "running shellcheck on test.sh"
206+
assert_output --partial "Files are ok"
207+
208+
unstub docker
209+
}
210+
211+
@test "Shellcheck uses default image when specified" {
212+
export BUILDKITE_PLUGIN_SHELLCHECK_FILES_0="tests/testdata/test.sh"
213+
export BUILDKITE_PLUGIN_SHELLCHECK_IMAGE="foo/shellcheck"
214+
export BUILDKITE_PLUGIN_SHELLCHECK_VERSION="bar"
215+
216+
stub docker \
217+
"run --rm -v $PWD:/mnt --workdir /mnt foo/shellcheck:bar --color=always tests/testdata/test.sh : echo running shellcheck on test.sh"
218+
219+
run "$PWD/hooks/command"
220+
221+
assert_success
222+
assert_output --partial "Running shellcheck on 1 files"
223+
assert_output --partial "running shellcheck on test.sh"
224+
assert_output --partial "Files are ok"
225+
226+
unstub docker
227+
}

0 commit comments

Comments
 (0)