-
Notifications
You must be signed in to change notification settings - Fork 38
/
integration-test.bats
83 lines (60 loc) · 1.6 KB
/
integration-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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#!/usr/bin/env bats
source lib/assert.bash
source deploy.sh --source-only
setup() {
tmp=`mktemp --tmpdir --directory deploy_test.XXXX`
pushd "$tmp" >/dev/null
create_repo
}
teardown() {
popd >/dev/null
rm -rf "$tmp"
}
create_repo() {
git init
[[ `git config user.name` ]] || git config user.name test
[[ `git config user.email` ]] || git config user.email test
git commit --allow-empty --message=empty
git remote add origin . # just "deploy" to this repo itself, for easy testing
mkdir dist
touch dist/file
}
@test "deploy creates branch and deploys file" {
main
git cat-file -e gh-pages:file # `file` exists on gh-pages
}
@test " deploys new file to existing branch" {
git branch gh-pages
main
git cat-file -e gh-pages:file # `file` exists on gh-pages
}
@test " updates existing file" {
main
echo updated > dist/file
main
[[ `git cat-file blob gh-pages:file` = updated ]]
}
@test " removes missing file" {
main
rm dist/file
main --allow-empty
! git cat-file -e gh-pages:file # `file` does not exist on gh-pages
}
@test " doesn't clobber file in deploy directory" {
# make sure that a source file doesn't overwrite a deploy file with the same name
echo source > file
echo dist > dist/file
git add file
git commit --message=file
main
[[ `cat dist/file` = dist ]]
[[ `git cat-file blob gh-pages:file` = dist ]]
}
@test " doesn't deploy source file" {
touch source
git add source
git commit --message='source file'
main
assert that `ls --almost-all dist` = file
! git cat-file -e gh-pages:source # `source` does not exist on gh-pages
}