Skip to content

Commit 0e9efe5

Browse files
committed
. dt verify json snippet
1 parent 66ef848 commit 0e9efe5

File tree

3 files changed

+16
-14
lines changed

3 files changed

+16
-14
lines changed

README.md

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -58,22 +58,11 @@ Note: ApprovalTests uses approvals to test itself. Therefore there are many exam
5858
## JSON
5959
VerifyJSONBytes - Simple Formatting for easy comparison. Also uses the .json file extension
6060

61-
```go
62-
func TestVerifyJSON(t *testing.T) {
63-
jsonb := []byte("{ \"foo\": \"bar\", \"age\": 42, \"bark\": \"woof\" }")
64-
VerifyJSONBytes(t, jsonb)
65-
}
66-
```
61+
snippet: verify_json
6762

68-
Matches file: approvals_test.TestVerifyJSON.received.json
63+
Matches file: `documentation_examples_test.TestVerifyJSON.approved.json`
6964

70-
```json
71-
{
72-
"age": 42,
73-
"bark": "woof",
74-
"foo": "bar"
75-
}
76-
```
65+
snippet: documentation_examples_test.TestVerifyJSON.approved.json
7766

7867
## Reporters
7968
ApprovalTests becomes _much_ more powerful with reporters. Reporters launch programs on failure to help you understand, fix and approve results.

documentation_examples/documentation_examples_test.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,11 @@ func TestHelloWorld(t *testing.T) {
1212
}
1313

1414
// end-snippet
15+
16+
// begin-snippet: verify_json
17+
func TestVerifyJSON(t *testing.T) {
18+
jsonb := []byte("{ \"foo\": \"bar\", \"age\": 42, \"bark\": \"woof\" }")
19+
approvals.VerifyJSONBytes(t, jsonb)
20+
}
21+
22+
// end-snippet
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"age": 42,
3+
"bark": "woof",
4+
"foo": "bar"
5+
}

0 commit comments

Comments
 (0)