forked from raviqqe/muffet
-
Notifications
You must be signed in to change notification settings - Fork 0
/
json_page_result_test.go
49 lines (44 loc) · 1010 Bytes
/
json_page_result_test.go
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
package main
import (
"encoding/json"
"errors"
"testing"
"github.com/bradleyjkemp/cupaloy"
"github.com/stretchr/testify/assert"
)
func TestMarshalErrorJSONPageResult(t *testing.T) {
bs, err := json.Marshal(newJSONPageResult(
&pageResult{
"http://foo.com",
[]*successLinkResult{},
[]*errorLinkResult{
{"http://foo.com/bar", errors.New("baz")},
},
}, false))
assert.Nil(t, err)
cupaloy.SnapshotT(t, bs)
}
func TestMarshalSuccessJSONPageResult(t *testing.T) {
bs, err := json.Marshal(newJSONPageResult(
&pageResult{
"http://foo.com",
[]*successLinkResult{
{"http://foo.com/foo", 200},
},
[]*errorLinkResult{},
}, false))
assert.Nil(t, err)
cupaloy.SnapshotT(t, bs)
}
func TestMarshalVerboseSuccessJSONPageResult(t *testing.T) {
bs, err := json.Marshal(newJSONPageResult(
&pageResult{
"http://foo.com",
[]*successLinkResult{
{"http://foo.com/foo", 200},
},
[]*errorLinkResult{},
}, true))
assert.Nil(t, err)
cupaloy.SnapshotT(t, bs)
}