Repository navigation
Expand file tree
/
Copy pathsmoke-test-config.bats
More file actions
192 lines (152 loc) · 4.59 KB
/
Copy pathsmoke-test-config.bats
File metadata and controls
192 lines (152 loc) · 4.59 KB
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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
#!/usr/bin/env bats
# Debugging
teardown() {
echo "Status: $status"
echo "Output:"
echo "================================================================"
for line in "${lines[@]}"; do
echo $line
done
echo "================================================================"
}
# Global skip
# Uncomment below, then comment skip in the test you want to debug. When done, reverse.
#SKIP=1
# Cannot do cleanup outside of a test case as bats will evaluate/run that code before every single test case.
@test "uber cleanup" {
[[ $SKIP == 1 ]] && skip
rm -rf .docksal
return 0
}
@test "fin config: empty project" {
[[ $SKIP == 1 ]] && skip
run fin config env
# Should through an error with an empty project
[[ $status != 0 ]]
}
@test "fin config: zero configuration" {
[[ $SKIP == 1 ]] && skip
# Create .docksal folder necessary for the zero-config setup
mkdir .docksal
run fin config env
[[ $status == 0 ]] && \
[[ $output =~ "volumes-bind.yml" ]] && \
[[ $output =~ "stack-default.yml" ]] && \
[[ ! $output =~ "docksal.yml" ]]
}
@test "fin config: zero configuration + stack option" {
[[ $SKIP == 1 ]] && skip
# Define which stack we want to use
echo 'DOCKSAL_STACK=acquia' > .docksal/docksal.env
run fin config env
[[ $status == 0 ]] && \
[[ $output =~ "volumes-bind.yml" ]] && \
[[ $output =~ "stack-acquia.yml" ]] && \
[[ ! $output =~ "docksal.yml" ]] && \
[[ $output =~ "docksal.env" ]]
}
@test "fin config: zero configuration + stack option + docksal.yml" {
[[ $SKIP == 1 ]] && skip
# Add a stack override via docksal.yml
yml="
version: '2.1'
services:
web:
environment:
- TEST_VAR=test_val"
echo "$yml" > .docksal/docksal.yml
run fin config
[[ $status == 0 ]] && \
[[ $output =~ "volumes-bind.yml" ]] && \
[[ $output =~ "stack-acquia.yml" ]] && \
[[ $output =~ "docksal.yml" ]] && \
[[ $output =~ "docksal.env" ]] && \
[[ $output =~ "TEST_VAR: test_val" ]]
}
@test "fin config: docksal.yml" {
[[ $SKIP == 1 ]] && skip
# cleanup here
rm -rf .docksal
mkdir .docksal
# Add a stack override via docksal.yml
yml="
version: '2.1'
services:
web:
image: nginx
environment:
- TEST_VAR="'${TEST_VAR:-test_val_default}'
echo "$yml" > .docksal/docksal.yml
run fin config
[[ $status == 0 ]] && \
[[ $output =~ "volumes-bind.yml" ]] && \
[[ ! $output =~ "stack-default.yml" ]] && \
[[ $output =~ "docksal.yml" ]] && \
[[ ! $output =~ "docksal.env" ]] && \
[[ $output =~ "TEST_VAR: test_val_default" ]]
}
@test "fin config: docksal.yml + docksal.env" {
[[ $SKIP == 1 ]] && skip
# Override TEST_VAR
echo 'TEST_VAR=my_val' > .docksal/docksal.env
run fin config
[[ $status == 0 ]] && \
[[ $output =~ "docksal.env" ]] && \
# Test our override is in place
[[ $output =~ "TEST_VAR: my_val" ]]
}
@test "fin config: docksal-local.yml" {
[[ $SKIP == 1 ]] && skip
# Add a stack override via docksal.yml
yml="
version: '2.1'
services:
web:
image: nginx
environment:
- TEST_VAR_LOCAL="'${TEST_VAR_LOCAL:-test_val_default}'
echo "$yml" > .docksal/docksal-local.yml
run fin config
[[ $status == 0 ]] && \
[[ $output =~ "docksal-local.yml" ]] && \
[[ ! $output =~ "docksal-local.env" ]] && \
[[ $output =~ "TEST_VAR_LOCAL: test_val_default" ]]
}
@test "fin config: docksal-local.yml + docksal-local.env" {
[[ $SKIP == 1 ]] && skip
# Override TEST_VAR_LOCAL
echo 'TEST_VAR_LOCAL=my_val_local' > .docksal/docksal-local.env
run fin config
[[ $status == 0 ]] && \
[[ $output =~ "docksal-local.yml" ]] && \
[[ $output =~ "docksal-local.env" ]] && \
# Test our override is in place
[[ $output =~ "TEST_VAR_LOCAL: my_val" ]]
}
@test "fin config generate: empty project" {
[[ $SKIP == 1 ]] && skip
# cleanup here
rm -rf .docksal
fin config generate
run fin config env
[[ $status == 0 ]] && \
[[ $output =~ "volumes-bind.yml" ]] && \
[[ ! $output =~ "stack-default.yml" ]] && \
[[ $output =~ "docksal.yml" ]] && \
[[ $output =~ "docksal.env" ]]
}
@test "fin config generate: existing project" {
[[ $SKIP == 1 ]] && skip
# Define which stack we want to use. This is supposed to be eventually removed by the "fin config generate" run below
echo 'DOCKSAL_STACK=acquia' > .docksal/docksal.env
# TODO: need a --force option to be able to use this in a non-interactive environment like CI/bats tests
# Run this non-interactively to avoid confirmation messages and thus getting stuck
echo "fin config generate" | bash
run fin config env
[[ $status == 0 ]] && \
[[ $output =~ "volumes-bind.yml" ]] && \
[[ ! $output =~ "stack-default.yml" ]] && \
[[ ! $output =~ "stack-acquia.yml" ]] && \
[[ $output =~ "docksal.yml" ]] && \
[[ $output =~ "docksal.env" ]]
}