Skip to content

Commit 19319f2

Browse files
committed
Added tests for multi-level behaviour
1 parent 6e3cc4c commit 19319f2

1 file changed

Lines changed: 43 additions & 0 deletions

File tree

tests/post-command.bats

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,3 +208,46 @@ teardown() {
208208

209209
unstub cache_dummy
210210
}
211+
212+
@test "Multiple level saving not forced" {
213+
export BUILDKITE_PLUGIN_CACHE_FORCE=false
214+
215+
export BUILDKITE_PLUGIN_CACHE_SAVE_0=all
216+
export BUILDKITE_PLUGIN_CACHE_SAVE_1=pipeline
217+
218+
stub cache_dummy \
219+
"exists \* \* : exit 0" \
220+
"exists \* \* : exit 1" \
221+
"save \* \* : echo saving \$3 in \$2"
222+
223+
run "$PWD/hooks/post-command"
224+
225+
assert_success
226+
assert_output --partial 'Saving all-level cache'
227+
refute_output --partial 'Saving pipeline-level cache'
228+
229+
unstub cache_dummy
230+
}
231+
232+
@test "Multiple level saving lower level change forces higher levels" {
233+
export BUILDKITE_PLUGIN_CACHE_FORCE=false
234+
235+
export BUILDKITE_PLUGIN_CACHE_SAVE_0=all
236+
export BUILDKITE_PLUGIN_CACHE_SAVE_1=pipeline
237+
export BUILDKITE_PLUGIN_CACHE_SAVE_2=step
238+
239+
stub cache_dummy \
240+
"exists \* \* : exit 0" \
241+
"exists \* \* : exit 1" \
242+
"save \* \* : echo saving \$3 in \$2" \
243+
"save \* \* : echo saving \$3 in \$2"
244+
245+
run "$PWD/hooks/post-command"
246+
247+
assert_success
248+
assert_output --partial 'Saving all-level cache'
249+
assert_output --partial 'Saving pipeline-level cache'
250+
refute_output --partial 'Saving step-level cache'
251+
252+
unstub cache_dummy
253+
}

0 commit comments

Comments
 (0)