MCPcopy
hub / github.com/gogf/gf / Test_Model_Handler

Function Test_Model_Handler

contrib/drivers/sqlitecgo/sqlitecgo_z_unit_model_test.go:3499–3521  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

3497}
3498
3499func Test_Model_Handler(t *testing.T) {
3500 table := createInitTable()
3501 defer dropTable(table)
3502
3503 gtest.C(t, func(t *gtest.T) {
3504 m := db.Model(table).Safe().Handler(
3505 func(m *gdb.Model) *gdb.Model {
3506 return m.Page(0, 3)
3507 },
3508 func(m *gdb.Model) *gdb.Model {
3509 return m.Where("id", g.Slice{1, 2, 3, 4, 5, 6})
3510 },
3511 func(m *gdb.Model) *gdb.Model {
3512 return m.OrderDesc("id")
3513 },
3514 )
3515 all, err := m.All()
3516 t.AssertNil(err)
3517 t.Assert(len(all), 3)
3518 t.Assert(all[0]["id"], 6)
3519 t.Assert(all[2]["id"], 4)
3520 })
3521}
3522
3523func Test_Model_FieldCount(t *testing.T) {
3524 table := createInitTable()

Callers

nothing calls this directly

Calls 12

CFunction · 0.92
HandlerMethod · 0.80
SafeMethod · 0.80
PageMethod · 0.80
OrderDescMethod · 0.80
AllMethod · 0.80
AssertNilMethod · 0.80
AssertMethod · 0.80
createInitTableFunction · 0.70
dropTableFunction · 0.70
ModelMethod · 0.65
WhereMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…