forked from mfcochauxlaberge/jsonapi
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjsonapi_test.go
91 lines (85 loc) · 1.62 KB
/
jsonapi_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
89
90
91
package jsonapi
import "time"
var (
mocktypes1 Collection
mocktypes2 Collection
mocktypes3 Collection
// urls []*URL
)
func init() {
loc, _ := time.LoadLocation("")
// Resources
mocktypes1 = WrapCollection(Wrap(&MockType1{}))
mocktypes1.Add(
Wrap(&MockType1{
ID: "mt1-1",
// Use default (zero) value for each attribute
}),
)
mocktypes1.Add(
Wrap(&MockType1{
ID: "mt1-2",
Str: "",
Int: -42,
Int8: 80,
Int16: 160,
Int32: 320,
Int64: 6464640000,
Uint: 42,
Uint8: 8,
Uint16: 1600,
Uint32: 32000,
Bool: false,
Time: time.Date(2017, 1, 2, 3, 4, 5, 6, loc),
}),
)
mocktypes2 = WrapCollection(Wrap(&MockType2{}))
mocktypes2.Add(
Wrap(&MockType2{
ID: "mt2-1",
// Use nil values
}),
)
strPtr := "str"
intPtr := int(-42)
int8Ptr := int8(80)
int16Ptr := int16(160)
int32Ptr := int32(320)
int64Ptr := int64(6464640000)
uintPtr := uint(42)
uint8Ptr := uint8(8)
uint16Ptr := uint16(1600)
uint32Ptr := uint32(32000)
boolPtr := false
timePtr := time.Date(2017, 1, 2, 3, 4, 5, 6, loc)
mocktypes2.Add(
Wrap(&MockType2{
ID: "mt1-2",
StrPtr: &strPtr,
IntPtr: &intPtr,
Int8Ptr: &int8Ptr,
Int16Ptr: &int16Ptr,
Int32Ptr: &int32Ptr,
Int64Ptr: &int64Ptr,
UintPtr: &uintPtr,
Uint8Ptr: &uint8Ptr,
Uint16Ptr: &uint16Ptr,
Uint32Ptr: &uint32Ptr,
BoolPtr: &boolPtr,
TimePtr: &timePtr,
}),
)
mocktypes3 = WrapCollection(Wrap(&MockType3{}))
mocktypes3.Add(
Wrap(&MockType3{
ID: "mt3-1",
}),
)
mocktypes3.Add(
Wrap(&MockType3{
ID: "mt3-1",
Attr1: "str",
Attr2: 32,
}),
)
}