-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathcommand.bats
57 lines (46 loc) · 2.05 KB
/
command.bats
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#!/usr/bin/env bats
load '/usr/local/lib/bats/load.bash'
# Uncomment to enable stub debug output:
# export AWS_STUB_DEBUG=/dev/tty
# export TAR_STUB_DEBUG=/dev/tty
@test "Post-checkout downloads cache" {
export BUILDKITE_PLUGIN_S3_CACHE_LOAD_SETTINGS=""
export BUILDKITE_PIPELINE_SLUG="test"
export BUILDKITE_BRANCH=master
export BUILDKITE_PLUGIN_S3_CACHE_BUCKET="test"
export BUILDKITE_PLUGIN_S3_CACHE_DIRECTORIES="./cache"
export BUILDKITE_LABEL="This test build"
export BUILDKITE_BUILD_CHECKOUT_PATH="$PWD"
stub aws \
"s3 ls s3://test/test/master/48ff2c8af2cb1b7b760080c23e4e1c92be6ee3cefef0ad8866d1d45b4485b195.tar.gz : echo 48ff2c8af2cb1b7b760080c23e4e1c92be6ee3cefef0ad8866d1d45b4485b195.tar.gz" \
"s3 ls s3://test/test/master/48ff2c8af2cb1b7b760080c23e4e1c92be6ee3cefef0ad8866d1d45b4485b195.tar.gz : echo 48ff2c8af2cb1b7b760080c23e4e1c92be6ee3cefef0ad8866d1d45b4485b195.tar.gz" \
"s3 cp s3://test/test/master/48ff2c8af2cb1b7b760080c23e4e1c92be6ee3cefef0ad8866d1d45b4485b195.tar.gz /tmp/48ff2c8af2cb1b7b760080c23e4e1c92be6ee3cefef0ad8866d1d45b4485b195.tar.gz : "
stub tar \
"-xzf : "
run "$PWD/hooks/post-checkout"
assert_success
assert_output --partial "Downloading cache from"
assert_output --partial "Uncompressing cache"
unstub aws
unstub tar
}
@test "Post-command upload cache" {
export BUILDKITE_PLUGIN_S3_CACHE_LOAD_SETTINGS=""
export BUILDKITE_PIPELINE_SLUG="test"
export BUILDKITE_BRANCH=master
export BUILDKITE_PLUGIN_S3_CACHE_BUCKET="test"
export BUILDKITE_PLUGIN_S3_CACHE_DIRECTORIES="tests/"
export BUILDKITE_LABEL="This test build"
export BUILDKITE_PLUGIN_S3_CACHE_FILE="/tmp/cache.tar.gz"
export BUILDKITE_BUILD_CHECKOUT_PATH="$PWD"
stub tar \
"-zcf : touch /tmp/cache.tar.gz"
stub aws \
"s3 cp /tmp/cache.tar.gz s3://test/test/master/48ff2c8af2cb1b7b760080c23e4e1c92be6ee3cefef0ad8866d1d45b4485b195.tar.gz : "
run "$PWD/hooks/post-command"
assert_success
assert_output --partial "Compressing cache with tar"
assert_output --partial "Uploading cache to"
unstub tar
unstub aws
}