MCPcopy
hub / github.com/go-gorm/gorm / TestQueryError

Function TestQueryError

tests/query_test.go:1442–1454  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

1440}
1441
1442func TestQueryError(t *testing.T) {
1443 type P struct{}
1444 var p1 P
1445 err := DB.Take(&p1, 1).Error
1446 AssertEqual(t, err, gorm.ErrModelAccessibleFieldsRequired)
1447
1448 var p2 interface{}
1449
1450 err = DB.Table("ps").Clauses(clause.Eq{Column: clause.Column{
1451 Table: clause.CurrentTable, Name: clause.PrimaryKey,
1452 }, Value: 1}).Scan(&p2).Error
1453 AssertEqual(t, err, gorm.ErrModelValueRequired)
1454}
1455
1456func TestQueryScanToArray(t *testing.T) {
1457 err := DB.Create(&User{Name: "testname1", Age: 10}).Error

Callers

nothing calls this directly

Calls 5

ClausesMethod · 0.80
TakeMethod · 0.65
ScanMethod · 0.65
TableMethod · 0.65
AssertEqualFunction · 0.50

Tested by

no test coverage detected