Skip to content

Commit

Permalink
Added extra test case for root object access function
Browse files Browse the repository at this point in the history
  • Loading branch information
jaredoconnell committed Apr 19, 2024
1 parent 41f4e39 commit 5c9a362
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions schema/scope_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -524,6 +524,19 @@ func TestMismatchedRoot(t *testing.T) {
}, "root object with ID \"wrong\" not found; available objects:\n\ta")
}

func TestMismatchedRootKey(t *testing.T) {
// Tests when the Root value and ID value are correct, but the key of the object map is wrong.
brokenSchema := schema.ScopeSchema{
ObjectsValue: map[string]*schema.ObjectSchema{
"wrong": schema.NewObjectSchema("a", map[string]*schema.PropertySchema{}),
},
RootValue: "a",
}
assert.PanicsContains(t, func() {
brokenSchema.RootObject()
}, "root object with ID \"a\" not found; available objects:\n\twrong")
}

func TestNilRoot(t *testing.T) {
// This is just a bug case; nil object in the objects map.
brokenSchema := schema.ScopeSchema{
Expand Down

0 comments on commit 5c9a362

Please sign in to comment.