forked from gobuffalo/pop
-
Notifications
You must be signed in to change notification settings - Fork 0
/
slices_test.go
64 lines (52 loc) · 1.19 KB
/
slices_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
package pop
import (
"time"
"github.com/gobuffalo/pop/slices"
)
type Cake struct {
ID int `db:"id"`
Int slices.Int `db:"int_slice"`
Float slices.Float `db:"float_slice"`
String slices.String `db:"string_slice"`
CreatedAt time.Time `json:"created_at" db:"created_at"`
UpdatedAt time.Time `json:"updated_at" db:"updated_at"`
}
func (p *PostgreSQLSuite) Test_String() {
transaction(func(tx *Connection) {
r := p.Require()
c := &Cake{
String: slices.String{"a", "b", "c"},
}
err := tx.Create(c)
r.NoError(err)
err = tx.Reload(c)
r.NoError(err)
r.Equal(slices.String{"a", "b", "c"}, c.String)
})
}
func (p *PostgreSQLSuite) Test_Int() {
transaction(func(tx *Connection) {
r := p.Require()
c := &Cake{
Int: slices.Int{1, 2, 3},
}
err := tx.Create(c)
r.NoError(err)
err = tx.Reload(c)
r.NoError(err)
r.Equal(slices.Int{1, 2, 3}, c.Int)
})
}
func (p *PostgreSQLSuite) Test_Float() {
transaction(func(tx *Connection) {
r := p.Require()
c := &Cake{
Float: slices.Float{1.0, 2.1, 3.2},
}
err := tx.Create(c)
r.NoError(err)
err = tx.Reload(c)
r.NoError(err)
r.Equal(slices.Float{1.0, 2.1, 3.2}, c.Float)
})
}