Reported by vacuum issue, this use-case is now handled correctly and prevents a panic.

Signed-off-by: quobix <dave@quobix.com>
This commit is contained in:
quobix
2023-11-05 09:16:08 -05:00
parent 3fb4865f08
commit ff40cfad85
2 changed files with 16 additions and 0 deletions

View File

@@ -317,6 +317,19 @@ func TestFindKeyNode(t *testing.T) {
assert.Equal(t, 47, k.Line)
}
func TestFindKeyNodeOffByOne(t *testing.T) {
k, v := FindKeyNode("key", []*yaml.Node{
{
Value: "key",
Line: 999,
},
})
assert.NotNil(t, k)
assert.NotNil(t, v)
assert.Equal(t, 999, k.Line)
}
func TestFindKeyNode_ValueIsKey(t *testing.T) {
a := &yaml.Node{