-
Notifications
You must be signed in to change notification settings - Fork 1
/
tests.bats
85 lines (71 loc) · 2.02 KB
/
tests.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
84
85
setup() {
PROJECT=$(mktemp -d)
git init ${PROJECT}
mkdir ${PROJECT}/docker
RUN=docker/run
cp -p run ${PROJECT}/${RUN}
pushd ${PROJECT} >/dev/null
}
teardown() {
popd >/dev/null
rm -rf ${PROJECT}
unset PROJECT RUN
}
@test "--self-update replaces run executable" {
touch -d 1982-02-05 ${RUN}
local before=$(stat -c '%Y' ${RUN})
${RUN} --self-update
local after=$(stat -c '%Y' ${RUN})
(( $before < $after ))
}
@test "run simple command" {
${RUN} --rm debian true
}
@test "failures are propagated" {
run ${RUN} --rm debian false
[[ $status == 1 ]]
}
@test "host user is known in container" {
local name=$(id -u -n)
run ${RUN} --rm debian id -u -n
[[ $output == $name ]]
}
@test "host group is known in container" {
local group=$(id -g -n)
run ${RUN} --rm debian id -g -n
[[ $output == $group ]]
}
@test "docker server is accessible" {
${RUN} --rm docker docker info
}
@test "home directories are persistent" {
local fileName=$(mktemp -p ${HOME})
${RUN} --rm debian touch ${fileName}
${RUN} --rm debian stat ${fileName}
}
@test "ssh agent is accessible" {
SSH_AUTH_SOCK=$(mktemp) ${RUN} --rm debian sh -c 'stat ${SSH_AUTH_SOCK}'
}
@test "current directory is preserved if a git repository is not available" {
local testFile=$(mktemp -p ${PROJECT})
rm -rf ${PROJECT}/.git
${RUN} --rm debian stat ${testFile##*/}
}
@test "current directory is mounted as /app if a git repository is not available" {
local testFile=$(mktemp -p ${PROJECT})
rm -rf ${PROJECT}/.git
${RUN} --rm debian stat /app/${testFile##*/}
}
@test "git root directory is mounted as /app" {
local testFile=$(mktemp -p ${PROJECT})
${RUN} --rm debian stat /app/${testFile##*/}
}
@test "git root is set as working directory" {
local testFile=$(mktemp -p ${PROJECT})
${RUN} --rm debian stat ${testFile##*/}
}
@test ".env file is used" {
echo "FOO=BAR" > ${PROJECT}/.env
run ${RUN} --rm debian sh -c 'echo ${FOO}'
[[ $output == "BAR" ]]
}