-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
864d5ba
commit 33b8ac0
Showing
13 changed files
with
234 additions
and
105 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
|
||
[TestMatchJSON/should_make_a_json_object_snapshot - 1] | ||
{ | ||
"mock-0": "value", | ||
"mock-1": 2, | ||
"mock-2": { | ||
"Msg": "Hello World" | ||
}, | ||
"mock-3": 10.4 | ||
} | ||
--- | ||
|
||
[TestMatchJSON/should_create_a_prettyJSON_snap - 1] | ||
{ | ||
"age": 10, | ||
"email": "mock@email.com", | ||
"user": "mock-user" | ||
} | ||
--- | ||
|
||
[TestMatchJSON/should_create_a_prettyJSON_snap - 2] | ||
{ | ||
"age": 10, | ||
"email": "mock@email.com", | ||
"user": "mock-user" | ||
} | ||
--- | ||
|
||
[TestMatchJSON/should_marshal_struct - 1] | ||
{ | ||
"email": "mock@email.com", | ||
"keys": [ | ||
1, | ||
2, | ||
3, | ||
4, | ||
5 | ||
], | ||
"name": "mock-name" | ||
} | ||
--- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
|
||
[TestMatchSnapshot/should_make_an_int_snapshot - 1] | ||
int(5) | ||
--- | ||
|
||
[TestMatchSnapshot/should_make_a_string_snapshot - 1] | ||
string snapshot | ||
--- | ||
|
||
[TestMatchSnapshot/should_make_a_map_snapshot - 1] | ||
map[string]interface {}{ | ||
"mock-0": "value", | ||
"mock-1": int(2), | ||
"mock-2": func() {...}, | ||
"mock-3": float32(10.399999618530273), | ||
} | ||
--- | ||
|
||
[TestMatchSnapshot/should_make_multiple_entries_in_snapshot - 1] | ||
int(5) | ||
int(10) | ||
int(20) | ||
int(25) | ||
--- | ||
|
||
[TestMatchSnapshot/should_make_create_multiple_snapshot - 1] | ||
int(1000) | ||
--- | ||
|
||
[TestMatchSnapshot/should_make_create_multiple_snapshot - 2] | ||
another snapshot | ||
--- | ||
|
||
[TestMatchSnapshot/should_make_create_multiple_snapshot - 3] | ||
{ | ||
"user": "gkampitakis", | ||
"id": 1234567, | ||
"data": [ ] | ||
} | ||
--- | ||
|
||
[TestMatchSnapshotTable/string - 1] | ||
input | ||
--- | ||
|
||
[TestMatchSnapshotTable/integer - 1] | ||
int(10) | ||
--- | ||
|
||
[TestMatchSnapshotTable/map - 1] | ||
map[string]interface {}{ | ||
"test": func() {...}, | ||
} | ||
--- | ||
|
||
[TestMatchSnapshot/nest/more/one_more_nested_test - 1] | ||
it's okay | ||
--- | ||
|
||
[TestMatchSnapshotTable/buffer - 1] | ||
&bytes.Buffer{ | ||
buf: {0x42, 0x75, 0x66, 0x66, 0x65, 0x72, 0x20, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67}, | ||
off: 0, | ||
lastRead: 0, | ||
} | ||
--- | ||
|
||
[TestMatchSnapshot/.* - 1] | ||
ignore regex patterns on names | ||
--- | ||
|
||
[TestSimpleTable/string - 1] | ||
input | ||
--- | ||
|
||
[TestSimpleTable/integer - 1] | ||
int(10) | ||
--- | ||
|
||
[TestSimpleTable/map - 1] | ||
map[string]interface {}{ | ||
"test": func() {...}, | ||
} | ||
--- | ||
|
||
[TestSimpleTable/buffer - 1] | ||
&bytes.Buffer{ | ||
buf: {0x42, 0x75, 0x66, 0x66, 0x65, 0x72, 0x20, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67}, | ||
off: 0, | ||
lastRead: 0, | ||
} | ||
--- |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package examples | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/gkampitakis/go-snaps/snaps" | ||
) | ||
|
||
func TestMatchJSON(t *testing.T) { | ||
t.Run("should make a json object snapshot", func(t *testing.T) { | ||
m := map[string]interface{}{ | ||
"mock-0": "value", | ||
"mock-1": 2, | ||
"mock-2": struct{ Msg string }{"Hello World"}, | ||
"mock-3": float32(10.4), | ||
} | ||
|
||
snaps.MatchJSON(t, m) | ||
}) | ||
|
||
t.Run("should create a prettyJSON snap", func(t *testing.T) { | ||
value := `{"user":"mock-user","age":10,"email":"mock@email.com"}` | ||
snaps.MatchJSON(t, value) | ||
snaps.MatchJSON(t, []byte(value)) | ||
}) | ||
|
||
t.Run("should marshal struct", func(t *testing.T) { | ||
type User struct { | ||
Name string `json:"name"` | ||
Email string `json:"email"` | ||
Keys []int `json:"keys"` | ||
} | ||
|
||
u := User{ | ||
Name: "mock-name", | ||
Email: "mock@email.com", | ||
Keys: []int{1, 2, 3, 4, 5}, | ||
} | ||
|
||
snaps.MatchJSON(t, u) | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.