/
githubmirror
/
pop
Обзор
Документация
Войти
/
githubmirror
/
pop
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
slices_test.go
66 строк
1 KB
Yonghwan SO
fixed empty slice bug on slices.Float
19 ноя 2022, 09:13
Не верифицирован
19 ноя 2022, 09:13
599fed6
Код
Авторство
О чём код?
package pop import ( "time" "github.com/gobuffalo/pop/v6/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 (s *PostgreSQLSuite) Test_String() { transaction(func(tx *Connection) { r := s.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 (s *PostgreSQLSuite) Test_Int() { transaction(func(tx *Connection) { r := s.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) r.Equal(slices.Float{}, c.Float) }) } func (s *PostgreSQLSuite) Test_Float() { transaction(func(tx *Connection) { r := s.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.Int{}, c.Int) r.Equal(slices.Float{1.0, 2.1, 3.2}, c.Float) }) }