Skip to content

Commit 5c25e10

Browse files
author
michael.biriley@firstaml.com
committed
Add tests for new functionality
1 parent e012ba5 commit 5c25e10

1 file changed

Lines changed: 47 additions & 0 deletions

File tree

tests/checkout.bats

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
#!/usr/bin/env bats
2+
3+
setup() {
4+
load "${BATS_PLUGIN_PATH}/load.bash"
5+
6+
# Uncomment to enable stub debugging
7+
# export CURL_STUB_DEBUG=/dev/tty
8+
9+
# you can set variables common to all tests here
10+
export BUILDKITE_PLUGIN_SPARSE_CHECKOUT_PATHS="default_path"
11+
export BUILDKITE_REPO_SSH_HOST="default_host"
12+
export BUILDKITE_COMMIT="dummy-commit-hash"
13+
}
14+
15+
@test "Skip ssh-keyscan when option provided" {
16+
export BUILDKITE_PLUGIN_SPARSE_CHECKOUT_SKIP_SSH_KEYSCAN='true'
17+
18+
stub git "clean \* : echo 'git clean'"
19+
stub git "fetch --depth 1 origin \* : echo 'git fetch'"
20+
stub git "sparse-checkout set \* \* : echo 'git sparse-checkout'"
21+
stub git "checkout \* : echo 'checkout'"
22+
23+
run "$PWD"/hooks/checkout
24+
25+
assert_success
26+
assert_output --partial 'Skipped SSH keyscan'
27+
28+
unstub git
29+
}
30+
31+
@test "Run ssh-keyscan when no option provided" {
32+
unset BUILDKITE_PLUGIN_SPARSE_CHECKOUT_SKIP_SSH_KEYSCAN
33+
34+
stub ssh-keyscan "\* : echo 'keyscan'"
35+
stub git "clean \* : echo 'git clean'"
36+
stub git "fetch --depth 1 origin \* : echo 'git fetch'"
37+
stub git "sparse-checkout set \* \* : echo 'git sparse-checkout'"
38+
stub git "checkout \* : echo 'checkout'"
39+
40+
run "$PWD"/hooks/checkout
41+
42+
assert_success
43+
assert_output --partial 'Scanning SSH keys for remote git repository'
44+
45+
unstub git
46+
unstub ssh-keyscan
47+
}

0 commit comments

Comments
 (0)