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

Function checkEmbeddedRelations

schema/schema_helper_test.go:209–233  ·  view source on GitHub ↗
(t *testing.T, actual map[string]*schema.Relationships, expected map[string]EmbeddedRelations)

Source from the content-addressed store, hash-verified

207}
208
209func checkEmbeddedRelations(t *testing.T, actual map[string]*schema.Relationships, expected map[string]EmbeddedRelations) {
210 for name, relations := range actual {
211 rs := expected[name]
212 t.Run("CheckEmbeddedRelations/"+name, func(t *testing.T) {
213 if len(relations.Relations) != len(rs.Relations) {
214 t.Errorf("schema relations count don't match, expects %d, got %d", len(rs.Relations), len(relations.Relations))
215 }
216 if len(relations.EmbeddedRelations) != len(rs.EmbeddedRelations) {
217 t.Errorf("schema embedded relations count don't match, expects %d, got %d", len(rs.EmbeddedRelations), len(relations.EmbeddedRelations))
218 }
219 for n, rel := range relations.Relations {
220 if r, ok := rs.Relations[n]; !ok {
221 t.Errorf("failed to find relation by name %s", n)
222 } else {
223 checkSchemaRelation(t, &schema.Schema{
224 Relationships: schema.Relationships{
225 Relations: map[string]*schema.Relationship{n: rel},
226 },
227 }, r)
228 }
229 }
230 checkEmbeddedRelations(t, relations.EmbeddedRelations, rs.EmbeddedRelations)
231 })
232 }
233}
234
235func checkField(t *testing.T, s *schema.Schema, value reflect.Value, values map[string]interface{}) {
236 for k, v := range values {

Callers 3

TestEmbeddedHasFunction · 0.85
TestPolymorphicFunction · 0.85
TestEmbeddedBelongsToFunction · 0.85

Calls 1

checkSchemaRelationFunction · 0.85

Tested by

no test coverage detected