Detect inheritance directives without paths
This commit is contained in:
@@ -121,6 +121,24 @@ func TestSiblingInheritanceRejectsInvalidRelationships(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestLoadDetectsInvalidInheritanceInsideSequence(t *testing.T) {
|
||||
input := []byte(`items:
|
||||
- child: {extends: true}
|
||||
`)
|
||||
result, err := testLoad[map[string]any](Bytes("nested-inheritance.yml", input), Options[map[string]any]{})
|
||||
if result != nil || err == nil {
|
||||
t.Fatalf("result, err = %#v, %v; want invalid nested inheritance", result, err)
|
||||
}
|
||||
loadError, ok := err.(*LoadError)
|
||||
if !ok {
|
||||
t.Fatalf("error type = %T, want *LoadError", err)
|
||||
}
|
||||
diagnostics := loadError.Diagnostics()
|
||||
if len(diagnostics) != 1 || diagnostics[0].Code != CodeInheritanceInvalid || diagnostics[0].Path.String() != "/items/0/child/extends" {
|
||||
t.Fatalf("diagnostics = %#v", diagnostics)
|
||||
}
|
||||
}
|
||||
|
||||
func TestSiblingInheritanceDetectsDeepCycleWithoutRecursiveDependencyWalk(t *testing.T) {
|
||||
const count = 2048
|
||||
entries := make([]document.Entry, count)
|
||||
|
||||
Reference in New Issue
Block a user