Fixed modelsvalidator.
This commit is contained in:
parent
4b90c1b2ba
commit
11213125fc
@ -71,7 +71,7 @@ func validateRelations(data map[string]models.Model) error {
|
|||||||
for _, c := range r.ToCollections() {
|
for _, c := range r.ToCollections() {
|
||||||
toModel, ok := data[c.Collection]
|
toModel, ok := data[c.Collection]
|
||||||
if !ok {
|
if !ok {
|
||||||
errs.append(fmt.Errorf("%s/%s directs to nonexisting model `%s`", modelName, fieldName, c))
|
errs.append(fmt.Errorf("%s/%s directs to nonexisting model `%s`", modelName, fieldName, c.Collection))
|
||||||
continue Next
|
continue Next
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -19,11 +19,6 @@ some_model:
|
|||||||
no_other_model:
|
no_other_model:
|
||||||
type: relation
|
type: relation
|
||||||
to: not_existing/field
|
to: not_existing/field
|
||||||
no_other_field:
|
|
||||||
type: relation
|
|
||||||
to: other_model/bar
|
|
||||||
other_model:
|
|
||||||
foo: string
|
|
||||||
`
|
`
|
||||||
|
|
||||||
const yamlNonExistingField = `---
|
const yamlNonExistingField = `---
|
||||||
@ -119,7 +114,7 @@ func TestCheck(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if !found {
|
if !found {
|
||||||
t.Errorf("Models.Check() returned %v, expected %v", gotErr, tt.err)
|
t.Errorf("Models.Check() returned:\n%v\n\nExpected something that contains:\n%v", gotErr, tt.err)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user