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

Function checkSchema

schema/schema_helper_test.go:14–37  ·  view source on GitHub ↗
(t *testing.T, s *schema.Schema, v *schema.Schema, primaryFields []string)

Source from the content-addressed store, hash-verified

12)
13
14func checkSchema(t *testing.T, s *schema.Schema, v *schema.Schema, primaryFields []string) {
15 t.Run("CheckSchema/"+s.Name, func(t *testing.T) {
16 tests.AssertObjEqual(t, s, v, "Name", "Table")
17
18 for idx, field := range primaryFields {
19 var found bool
20 for _, f := range s.PrimaryFields {
21 if f.Name == field {
22 found = true
23 }
24 }
25
26 if idx == 0 {
27 if field != s.PrioritizedPrimaryField.Name {
28 t.Errorf("schema %v prioritized primary field should be %v, but got %v", s, field, s.PrioritizedPrimaryField.Name)
29 }
30 }
31
32 if !found {
33 t.Errorf("schema %v failed to found primary key: %v", s, field)
34 }
35 }
36 })
37}
38
39func checkSchemaField(t *testing.T, s *schema.Schema, f *schema.Field, fc func(*schema.Field)) {
40 t.Run("CheckField/"+f.Name, func(t *testing.T) {

Callers 2

checkUserSchemaFunction · 0.85

Calls 1

AssertObjEqualFunction · 0.92

Tested by

no test coverage detected