-
Notifications
You must be signed in to change notification settings - Fork 8
/
jsonapi_test.go
60 lines (48 loc) · 1.67 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
package jsonapi_test
import (
"flag"
"time"
. "github.com/mfcochauxlaberge/jsonapi"
)
// This is for backward compatibility with
// Go versions under 1.18.
type any = interface{}
var update = flag.Bool("update-golden-files", false, "update the golden files")
func getTime() time.Time {
now, _ := time.Parse(time.RFC3339Nano, "2013-06-24T22:03:34.8276Z")
return now
}
var _ MetaHolder = (*mocktype)(nil)
// mocktype is a fake struct that defines a JSON:API type for test purposes.
type mocktype struct {
ID string `json:"id" api:"mocktype"`
// Attributes
Str string `json:"str" api:"attr"`
Int int `json:"int" api:"attr"`
Int8 int8 `json:"int8" api:"attr"`
Int16 int16 `json:"int16" api:"attr"`
Int32 int32 `json:"int32" api:"attr"`
Int64 int64 `json:"int64" api:"attr"`
Uint uint `json:"uint" api:"attr"`
Uint8 uint8 `json:"uint8" api:"attr"`
Uint16 uint16 `json:"uint16" api:"attr"`
Uint32 uint32 `json:"uint32" api:"attr"`
Uint64 uint64 `json:"uint64" api:"attr"`
Bool bool `json:"bool" api:"attr"`
Time time.Time `json:"time" api:"attr"`
Bytes []byte `json:"bytes" api:"attr"`
// Relationships
To1 string `json:"to-1" api:"rel,mocktype"`
To1From1 string `json:"to-1-from-1" api:"rel,mocktype,to-1-from-1"`
To1FromX string `json:"to-1-from-x" api:"rel,mocktype,to-x-from-1"`
ToX []string `json:"to-x" api:"rel,mocktype"`
ToXFrom1 []string `json:"to-x-from-1" api:"rel,mocktype,to-1-from-x"`
ToXFromX []string `json:"to-x-from-x" api:"rel,mocktype,to-x-from-x"`
meta Meta
}
func (mt *mocktype) Meta() Meta {
return mt.meta
}
func (mt *mocktype) SetMeta(m Meta) {
mt.meta = m
}