-
Notifications
You must be signed in to change notification settings - Fork 57
/
Copy pathtest.bats
executable file
·69 lines (50 loc) · 1.63 KB
/
test.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
58
59
60
61
62
63
64
65
66
67
68
69
#!/usr/bin/env bats
setup(){
export PATH="/usr/local/mock:/usr/bin"
cat /dev/null >| mockArgs
cat /dev/null >| mockStdin
declare -A -p MOCK_RETURNS=(
['/usr/local/mock/gh']=""
['/usr/local/mock/cd']=""
) > mockReturns
export INPUT_TITLE='TITLE'
}
teardown() {
unset INPUT_WORKDIR
unset INPUT_TAG
unset INPUT_PRERELEASE
}
@test "it creates a release" {
run /entrypoint.sh
expectMockCalledIs "/usr/local/mock/gh release create release-$(date +%Y%m%d%H%M%S) -t TITLE --generate-notes"
}
@test "it creates a release with a predefined tag" {
export INPUT_TAG="TAG"
run /entrypoint.sh
expectMockCalledIs "/usr/local/mock/gh release create ${INPUT_TAG} -t TITLE --generate-notes"
}
@test "it creates a release in a working directory" {
export INPUT_WORKDIR="WORKDIR"
export INPUT_TAG="TAG"
run /entrypoint.sh
expectMockCalledIs "/usr/local/mock/gh release create ${INPUT_TAG} -t TITLE --generate-notes"
}
@test "it creates a prerelease" {
export INPUT_TAG="TAG"
export INPUT_PRERELEASE="true"
run /entrypoint.sh
expectMockCalledIs "/usr/local/mock/gh release create ${INPUT_TAG} -t TITLE --generate-notes --prerelease"
}
@test "it doesn't create a prerelease on false" {
export INPUT_TAG="TAG"
export INPUT_PRERELEASE="false"
run /entrypoint.sh
expectMockCalledIs "/usr/local/mock/gh release create ${INPUT_TAG} -t TITLE --generate-notes"
}
expectMockCalledIs() {
local expected=$(echo "${1}" | tr -d '\n')
local got=$(cat mockArgs | tr -d '\n')
echo "Expected: |${expected}|
Got: |${got}|"
[ "${got}" == "${expected}" ]
}