forked from google/jsonapi
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhelpers_test.go
88 lines (85 loc) · 1.31 KB
/
helpers_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
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
package jsonapi
import (
"encoding/json"
"reflect"
"time"
)
func isJSONEqual(b1, b2 []byte) (bool, error) {
var i1, i2 interface{}
var result bool
var err error
if err = json.Unmarshal(b1, &i1); err != nil {
return result, err
}
if err = json.Unmarshal(b2, &i2); err != nil {
return result, err
}
result = reflect.DeepEqual(i1, i2)
return result, err
}
func testBlog() *Blog {
return &Blog{
ID: 5,
Title: "Title 1",
CreatedAt: time.Now(),
Posts: []*Post{
&Post{
ID: 1,
Title: "Foo",
Body: "Bar",
Comments: []*Comment{
&Comment{
ID: 1,
Body: "foo",
},
&Comment{
ID: 2,
Body: "bar",
},
},
LatestComment: &Comment{
ID: 1,
Body: "foo",
},
},
&Post{
ID: 2,
Title: "Fuubar",
Body: "Bas",
Comments: []*Comment{
&Comment{
ID: 1,
Body: "foo",
},
&Comment{
ID: 3,
Body: "bas",
},
},
LatestComment: &Comment{
ID: 1,
Body: "foo",
},
},
},
CurrentPost: &Post{
ID: 1,
Title: "Foo",
Body: "Bar",
Comments: []*Comment{
&Comment{
ID: 1,
Body: "foo",
},
&Comment{
ID: 2,
Body: "bar",
},
},
LatestComment: &Comment{
ID: 1,
Body: "foo",
},
},
}
}