Skip to content

Commit a7e9985

Browse files
authored
Merge pull request #3277 from st3penta/fix-acceptance-snaps
Fix UPDATE_SNAPS support in make acceptance
2 parents 03d43b0 + 172de47 commit a7e9985

12 files changed

Lines changed: 260 additions & 1475 deletions

Makefile

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,14 @@ acceptance: ## Run all acceptance tests
126126
ACCEPTANCE_WORKDIR="$$(mktemp -d)"; \
127127
cleanup() { \
128128
cp "$${ACCEPTANCE_WORKDIR}"/features/__snapshots__/* "$(ROOT_DIR)"/features/__snapshots__/ || true; \
129+
if [ -n "$${UPDATE_SNAPS}" ]; then \
130+
for f in "$(ROOT_DIR)"/features/__snapshots__/*.snap; do \
131+
[ -f "$$f" ] || continue; \
132+
if [ ! -f "$${ACCEPTANCE_WORKDIR}/features/__snapshots__/$$(basename $$f)" ]; then \
133+
rm -f "$$f"; \
134+
fi; \
135+
done; \
136+
fi; \
129137
rm -rf "$${ACCEPTANCE_WORKDIR}"; \
130138
}; \
131139
mkdir -p "$${ACCEPTANCE_WORKDIR}/coverage"; \

acceptance/snaps/snaps.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ func (e errCapture) SkipNow() {
6969
}
7070

7171
func (e errCapture) Name() string {
72-
return e.scenario.Name + ":" + e.qualifier
72+
return "TestFeatures/" + e.scenario.Name + ":" + e.qualifier
7373
}
7474

7575
func (e *errCapture) Error(args ...interface{}) {

features/__snapshots__/conftest_test.snap

100755100644
Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11

2-
[appstudio error nofail:stdout - 1]
2+
[TestFeatures/appstudio error nofail:stdout - 1]
33
{
44
"timestamp": "${TIMESTAMP}",
55
"namespace": "",
@@ -11,12 +11,12 @@
1111
}
1212
---
1313

14-
[appstudio error nofail:stderr - 1]
14+
[TestFeatures/appstudio error nofail:stderr - 1]
1515
Error: running test: load: loading policies: load: 1 error occurred during loading: stat file/not/exist.rego: no such file or directory
1616

1717
---
1818

19-
[appstudio warning:stdout - 1]
19+
[TestFeatures/appstudio warning:stdout - 1]
2020
{
2121
"timestamp": "${TIMESTAMP}",
2222
"namespace": "main",
@@ -28,11 +28,11 @@ Error: running test: load: loading policies: load: 1 error occurred during loadi
2828
}
2929
---
3030

31-
[appstudio warning:stderr - 1]
31+
[TestFeatures/appstudio warning:stderr - 1]
3232

3333
---
3434

35-
[a warning:stdout - 1]
35+
[TestFeatures/a warning:stdout - 1]
3636
[
3737
{
3838
"filename": "acceptance/examples/empty_input.json",
@@ -50,11 +50,11 @@ Error: running test: load: loading policies: load: 1 error occurred during loadi
5050
]
5151
---
5252

53-
[a warning:stderr - 1]
53+
[TestFeatures/a warning:stderr - 1]
5454

5555
---
5656

57-
[a different appstudio error:stdout - 1]
57+
[TestFeatures/a different appstudio error:stdout - 1]
5858
{
5959
"timestamp": "${TIMESTAMP}",
6060
"namespace": "",
@@ -66,12 +66,12 @@ Error: running test: load: loading policies: load: 1 error occurred during loadi
6666
}
6767
---
6868

69-
[a different appstudio error:stderr - 1]
69+
[TestFeatures/a different appstudio error:stderr - 1]
7070
Error: running test: parse configurations: parser unmarshal: unmarshal json: invalid character '\n' in string literal, path: acceptance/examples/broken_input.json
7171

7272
---
7373

74-
[appstudio success:stdout - 1]
74+
[TestFeatures/appstudio success:stdout - 1]
7575
{
7676
"timestamp": "${TIMESTAMP}",
7777
"namespace": "main",
@@ -83,7 +83,7 @@ Error: running test: parse configurations: parser unmarshal: unmarshal json: inv
8383
}
8484
---
8585

86-
[a deny with no-fail:stdout - 1]
86+
[TestFeatures/a deny with no-fail:stdout - 1]
8787
[
8888
{
8989
"filename": "acceptance/examples/empty_input.json",
@@ -101,15 +101,15 @@ Error: running test: parse configurations: parser unmarshal: unmarshal json: inv
101101
]
102102
---
103103

104-
[appstudio success:stderr - 1]
104+
[TestFeatures/appstudio success:stderr - 1]
105105

106106
---
107107

108-
[a deny with no-fail:stderr - 1]
108+
[TestFeatures/a deny with no-fail:stderr - 1]
109109

110110
---
111111

112-
[appstudio deny:stdout - 1]
112+
[TestFeatures/appstudio deny:stdout - 1]
113113
{
114114
"timestamp": "${TIMESTAMP}",
115115
"namespace": "main",
@@ -121,7 +121,7 @@ Error: running test: parse configurations: parser unmarshal: unmarshal json: inv
121121
}
122122
---
123123

124-
[a deny:stdout - 1]
124+
[TestFeatures/a deny:stdout - 1]
125125
[
126126
{
127127
"filename": "acceptance/examples/empty_input.json",
@@ -139,15 +139,15 @@ Error: running test: parse configurations: parser unmarshal: unmarshal json: inv
139139
]
140140
---
141141

142-
[appstudio deny:stderr - 1]
142+
[TestFeatures/appstudio deny:stderr - 1]
143143

144144
---
145145

146-
[a deny:stderr - 1]
146+
[TestFeatures/a deny:stderr - 1]
147147

148148
---
149149

150-
[a warning with fail-on-warn:stdout - 1]
150+
[TestFeatures/a warning with fail-on-warn:stdout - 1]
151151
[
152152
{
153153
"filename": "acceptance/examples/empty_input.json",
@@ -165,11 +165,11 @@ Error: running test: parse configurations: parser unmarshal: unmarshal json: inv
165165
]
166166
---
167167

168-
[a warning with fail-on-warn:stderr - 1]
168+
[TestFeatures/a warning with fail-on-warn:stderr - 1]
169169

170170
---
171171

172-
[appstudio skipped:stdout - 1]
172+
[TestFeatures/appstudio skipped:stdout - 1]
173173
{
174174
"timestamp": "${TIMESTAMP}",
175175
"namespace": "main",
@@ -181,22 +181,22 @@ Error: running test: parse configurations: parser unmarshal: unmarshal json: inv
181181
}
182182
---
183183

184-
[appstudio skipped:stderr - 1]
184+
[TestFeatures/appstudio skipped:stderr - 1]
185185

186186
---
187187

188-
[plain text deny:stdout - 1]
188+
[TestFeatures/plain text deny:stdout - 1]
189189
FAIL - acceptance/examples/empty_input.json - main - Failure due to overripeness
190190

191191
1 test, 0 passed, 0 warnings, 1 failure, 0 exceptions
192192

193193
---
194194

195-
[plain text deny:stderr - 1]
195+
[TestFeatures/plain text deny:stderr - 1]
196196

197197
---
198198

199-
[appstudio error:stdout - 1]
199+
[TestFeatures/appstudio error:stdout - 1]
200200
{
201201
"timestamp": "${TIMESTAMP}",
202202
"namespace": "",
@@ -208,21 +208,21 @@ FAIL - acceptance/examples/empty_input.json - main - Failure due to overripeness
208208
}
209209
---
210210

211-
[normal error:stdout - 1]
211+
[TestFeatures/normal error:stdout - 1]
212212

213213
---
214214

215-
[appstudio error:stderr - 1]
215+
[TestFeatures/appstudio error:stderr - 1]
216216
Error: running test: load: loading policies: load: 1 error occurred during loading: stat file/not/exist.rego: no such file or directory
217217

218218
---
219219

220-
[normal error:stderr - 1]
220+
[TestFeatures/normal error:stderr - 1]
221221
Error: running test: load: loading policies: load: 1 error occurred during loading: stat file/not/exist.rego: no such file or directory
222222

223223
---
224224

225-
[success:stdout - 1]
225+
[TestFeatures/success:stdout - 1]
226226
[
227227
{
228228
"filename": "acceptance/examples/empty_input.json",
@@ -232,6 +232,6 @@ Error: running test: load: loading policies: load: 1 error occurred during loadi
232232
]
233233
---
234234

235-
[success:stderr - 1]
235+
[TestFeatures/success:stderr - 1]
236236

237237
---

features/__snapshots__/initialize.snap

100755100644
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11

2-
[success:stdout - 1]
2+
[TestFeatures/success:stdout - 1]
33
[
44
{
55
"filename": "acceptance/examples/empty_input.json",
@@ -9,11 +9,11 @@
99
]
1010
---
1111

12-
[success:stderr - 1]
12+
[TestFeatures/success:stderr - 1]
1313

1414
---
1515

16-
[appstudio success:stdout - 1]
16+
[TestFeatures/appstudio success:stdout - 1]
1717
{
1818
"timestamp": "${TIMESTAMP}",
1919
"namespace": "main",
@@ -25,6 +25,6 @@
2525
}
2626
---
2727

28-
[appstudio success:stderr - 1]
28+
[TestFeatures/appstudio success:stderr - 1]
2929

3030
---

features/__snapshots__/inspect_policy.snap

100755100644
Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11

2-
[inspecting a data source:stdout - 1]
2+
[TestFeatures/inspecting a data source:stdout - 1]
33
{
44
"rule_data": {
55
"banana_fail_reason": "spider attack"
@@ -8,29 +8,29 @@
88
}
99
---
1010

11-
[inspecting a data source:stderr - 1]
11+
[TestFeatures/inspecting a data source:stderr - 1]
1212

1313
---
1414

15-
[short names output:stdout - 1]
15+
[TestFeatures/short names output:stdout - 1]
1616
kitty.purr
1717

1818
---
1919

20-
[short names output:stderr - 1]
20+
[TestFeatures/short names output:stderr - 1]
2121

2222
---
2323

24-
[inspecting a data source with a merge error:stdout - 1]
24+
[TestFeatures/inspecting a data source with a merge error:stdout - 1]
2525

2626
---
2727

28-
[inspecting a data source with a merge error:stderr - 1]
28+
[TestFeatures/inspecting a data source with a merge error:stderr - 1]
2929
Error: Merge error. The 'rule_data' key was found more than once!
3030

3131
---
3232

33-
[json output:stdout - 1]
33+
[TestFeatures/json output:stdout - 1]
3434
{
3535
"git::${GITHOST}/git/policy.git?ref=${LATEST_COMMIT}": [
3636
{
@@ -66,11 +66,11 @@ Error: Merge error. The 'rule_data' key was found more than once!
6666
}
6767
---
6868

69-
[json output:stderr - 1]
69+
[TestFeatures/json output:stderr - 1]
7070

7171
---
7272

73-
[default output:stdout - 1]
73+
[TestFeatures/default output:stdout - 1]
7474
# Source: git::${GITHOST}/git/policy.git?ref=${LATEST_COMMIT}
7575

7676
kitty.purr (deny)
@@ -81,11 +81,11 @@ Fluffy
8181

8282
---
8383

84-
[default output:stderr - 1]
84+
[TestFeatures/default output:stderr - 1]
8585

8686
---
8787

88-
[sources from ECP:stdout - 1]
88+
[TestFeatures/sources from ECP:stdout - 1]
8989
# Source: git::${GITHOST}/git/policy1.git?ref=f81eaf65be8da58460ff920408ba1313051184a1
9090

9191
kitty.purr (deny)
@@ -110,6 +110,6 @@ This rule will always fail
110110

111111
---
112112

113-
[sources from ECP:stderr - 1]
113+
[TestFeatures/sources from ECP:stderr - 1]
114114

115115
---

features/__snapshots__/opa.snap

100755100644
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11

2-
[OPA sub-command is available:stdout - 1]
2+
[TestFeatures/OPA sub-command is available:stdout - 1]
33
An open source project to policy-enable your service.
44

55
Usage:
@@ -42,6 +42,6 @@ Use "ec opa [command] --help" for more information about a command.
4242

4343
---
4444

45-
[OPA sub-command is available:stderr - 1]
45+
[TestFeatures/OPA sub-command is available:stderr - 1]
4646

4747
---

features/__snapshots__/ta_task_validate_image.snap

100755100644
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11

2-
[Golden container image with trusted artifacts:report-json - 1]
2+
[TestFeatures/Golden container image with trusted artifacts:report-json - 1]
33
{
44
"success": true,
55
"components": [
@@ -131,14 +131,14 @@
131131
}
132132
---
133133

134-
[Golden container image with trusted artifacts:results - 1]
134+
[TestFeatures/Golden container image with trusted artifacts:results - 1]
135135
{
136136
"TEST_OUTPUT": "{\"timestamp\":\"${TIMESTAMP}\",\"namespace\":\"\",\"successes\":5,\"failures\":0,\"warnings\":0,\"result\":\"SUCCESS\"}\n",
137137
"VSA_GENERATED": "false"
138138
}
139139
---
140140

141-
[Golden container image with trusted artifacts:show-config - 1]
141+
[TestFeatures/Golden container image with trusted artifacts:show-config - 1]
142142
{
143143
"policy": {
144144
"sources": [

0 commit comments

Comments
 (0)