github.com/dolanor/pop@v4.13.0+incompatible/slices_test.go (about) 1 package pop 2 3 import ( 4 "time" 5 6 "github.com/gobuffalo/pop/slices" 7 ) 8 9 type Cake struct { 10 ID int `db:"id"` 11 Int slices.Int `db:"int_slice"` 12 Float slices.Float `db:"float_slice"` 13 String slices.String `db:"string_slice"` 14 CreatedAt time.Time `json:"created_at" db:"created_at"` 15 UpdatedAt time.Time `json:"updated_at" db:"updated_at"` 16 } 17 18 func (p *PostgreSQLSuite) Test_String() { 19 transaction(func(tx *Connection) { 20 r := p.Require() 21 22 c := &Cake{ 23 String: slices.String{"a", "b", "c"}, 24 } 25 err := tx.Create(c) 26 r.NoError(err) 27 28 err = tx.Reload(c) 29 r.NoError(err) 30 r.Equal(slices.String{"a", "b", "c"}, c.String) 31 }) 32 } 33 34 func (p *PostgreSQLSuite) Test_Int() { 35 transaction(func(tx *Connection) { 36 r := p.Require() 37 38 c := &Cake{ 39 Int: slices.Int{1, 2, 3}, 40 } 41 err := tx.Create(c) 42 r.NoError(err) 43 44 err = tx.Reload(c) 45 r.NoError(err) 46 r.Equal(slices.Int{1, 2, 3}, c.Int) 47 }) 48 } 49 50 func (p *PostgreSQLSuite) Test_Float() { 51 transaction(func(tx *Connection) { 52 r := p.Require() 53 54 c := &Cake{ 55 Float: slices.Float{1.0, 2.1, 3.2}, 56 } 57 err := tx.Create(c) 58 r.NoError(err) 59 60 err = tx.Reload(c) 61 r.NoError(err) 62 r.Equal(slices.Float{1.0, 2.1, 3.2}, c.Float) 63 }) 64 }