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

Function CheckIndices

schema/index_test.go:254–275  ·  view source on GitHub ↗
(t *testing.T, expected, actual []*schema.Index)

Source from the content-addressed store, hash-verified

252}
253
254func CheckIndices(t *testing.T, expected, actual []*schema.Index) {
255 if len(expected) != len(actual) {
256 t.Errorf("expected %d indices, but got %d", len(expected), len(actual))
257 return
258 }
259
260 for i, ei := range expected {
261 t.Run(ei.Name, func(t *testing.T) {
262 ai := actual[i]
263 tests.AssertObjEqual(t, ai, ei, "Name", "Class", "Type", "Where", "Comment", "Option")
264
265 if len(ei.Fields) != len(ai.Fields) {
266 t.Errorf("expected index %q field length is %d but actual %d", ei.Name, len(ei.Fields), len(ai.Fields))
267 return
268 }
269 for i, ef := range ei.Fields {
270 af := ai.Fields[i]
271 tests.AssertObjEqual(t, af, ef, "Name", "Unique", "UniqueIndex", "Expression", "Sort", "Collate", "Length", "NotNull")
272 }
273 })
274 }
275}

Callers 2

TestParseIndexFunction · 0.85

Calls 1

AssertObjEqualFunction · 0.92

Tested by

no test coverage detected