-
Notifications
You must be signed in to change notification settings - Fork 0
/
suite_test.go
62 lines (48 loc) · 993 Bytes
/
suite_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
package inflate_test
import (
"database/sql"
"testing"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
)
func TestEncoding(t *testing.T) {
RegisterFailHandler(Fail)
RunSpecs(t, "Encoding Suite")
}
type TValue struct {
Value uint `fake:"99"`
}
type User struct {
Name string `json:"name" fake:"value" default:"John"`
}
type Account struct {
User *User `fake:"user"`
}
type Nested struct {
ID string `fake:"id"`
User *User `fake:"~"`
Map map[string]interface{} `fake:"~"`
}
type Row struct {
Result sql.NullInt64 `fake:"result"`
}
type RowInt struct {
Result int64 `fake:"result"`
}
type Text struct {
Value string `fake:"value"`
Error error `fake:"error"`
}
func (t *Text) UnmarshalText(data []byte) error {
if t.Error != nil {
return t.Error
}
*t = Text{Value: string(data)}
return nil
}
func (t Text) MarshalText() ([]byte, error) {
if t.Error != nil {
return nil, t.Error
}
return []byte(t.Value), nil
}