mirror of
https://github.com/LukeHagar/libopenapi.git
synced 2025-12-07 04:20:14 +00:00
A massive test update to bring everything inlne with the new Buildable signature.
All tests in index and datamodel now pass. The rolodex fixes all the things. Signed-off-by: quobix <dave@quobix.com>
This commit is contained in:
@@ -4,6 +4,7 @@
|
||||
package low
|
||||
|
||||
import (
|
||||
"context"
|
||||
"crypto/sha256"
|
||||
"fmt"
|
||||
"strings"
|
||||
@@ -61,7 +62,7 @@ func TestLocateRefNode(t *testing.T) {
|
||||
var cNode yaml.Node
|
||||
_ = yaml.Unmarshal([]byte(yml), &cNode)
|
||||
|
||||
located, _ := LocateRefNode(cNode.Content[0], idx)
|
||||
located, _, _ := LocateRefNode(cNode.Content[0], idx)
|
||||
assert.NotNil(t, located)
|
||||
|
||||
}
|
||||
@@ -83,7 +84,7 @@ func TestLocateRefNode_BadNode(t *testing.T) {
|
||||
var cNode yaml.Node
|
||||
_ = yaml.Unmarshal([]byte(yml), &cNode)
|
||||
|
||||
located, err := LocateRefNode(cNode.Content[0], idx)
|
||||
located, _, err := LocateRefNode(cNode.Content[0], idx)
|
||||
|
||||
// should both be empty.
|
||||
assert.Nil(t, located)
|
||||
@@ -107,7 +108,7 @@ func TestLocateRefNode_Path(t *testing.T) {
|
||||
var cNode yaml.Node
|
||||
_ = yaml.Unmarshal([]byte(yml), &cNode)
|
||||
|
||||
located, _ := LocateRefNode(cNode.Content[0], idx)
|
||||
located, _, _ := LocateRefNode(cNode.Content[0], idx)
|
||||
assert.NotNil(t, located)
|
||||
|
||||
}
|
||||
@@ -128,7 +129,7 @@ func TestLocateRefNode_Path_NotFound(t *testing.T) {
|
||||
var cNode yaml.Node
|
||||
_ = yaml.Unmarshal([]byte(yml), &cNode)
|
||||
|
||||
located, err := LocateRefNode(cNode.Content[0], idx)
|
||||
located, _, err := LocateRefNode(cNode.Content[0], idx)
|
||||
assert.Nil(t, located)
|
||||
assert.Error(t, err)
|
||||
|
||||
@@ -138,7 +139,7 @@ type pizza struct {
|
||||
Description NodeReference[string]
|
||||
}
|
||||
|
||||
func (p *pizza) Build(_, _ *yaml.Node, _ *index.SpecIndex) error {
|
||||
func (p *pizza) Build(_ context.Context, _, _ *yaml.Node, _ *index.SpecIndex) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -160,7 +161,7 @@ func TestExtractObject(t *testing.T) {
|
||||
var cNode yaml.Node
|
||||
_ = yaml.Unmarshal([]byte(yml), &cNode)
|
||||
|
||||
tag, err := ExtractObject[*pizza]("tags", &cNode, idx)
|
||||
tag, err := ExtractObject[*pizza](context.Background(), "tags", &cNode, idx)
|
||||
assert.NoError(t, err)
|
||||
assert.NotNil(t, tag)
|
||||
assert.Equal(t, "hello pizza", tag.Value.Description.Value)
|
||||
@@ -184,7 +185,7 @@ func TestExtractObject_Ref(t *testing.T) {
|
||||
var cNode yaml.Node
|
||||
_ = yaml.Unmarshal([]byte(yml), &cNode)
|
||||
|
||||
tag, err := ExtractObject[*pizza]("tags", &cNode, idx)
|
||||
tag, err := ExtractObject[*pizza](context.Background(), "tags", &cNode, idx)
|
||||
assert.NoError(t, err)
|
||||
assert.NotNil(t, tag)
|
||||
assert.Equal(t, "hello pizza", tag.Value.Description.Value)
|
||||
@@ -210,7 +211,7 @@ func TestExtractObject_DoubleRef(t *testing.T) {
|
||||
var cNode yaml.Node
|
||||
_ = yaml.Unmarshal([]byte(yml), &cNode)
|
||||
|
||||
tag, err := ExtractObject[*pizza]("tags", &cNode, idx)
|
||||
tag, err := ExtractObject[*pizza](context.Background(), "tags", &cNode, idx)
|
||||
assert.NoError(t, err)
|
||||
assert.NotNil(t, tag)
|
||||
assert.Equal(t, "cake time!", tag.Value.Description.Value)
|
||||
@@ -241,7 +242,7 @@ func TestExtractObject_DoubleRef_Circular(t *testing.T) {
|
||||
var cNode yaml.Node
|
||||
_ = yaml.Unmarshal([]byte(yml), &cNode)
|
||||
|
||||
_, err := ExtractObject[*pizza]("tags", &cNode, idx)
|
||||
_, err := ExtractObject[*pizza](context.Background(), "tags", &cNode, idx)
|
||||
assert.Error(t, err)
|
||||
assert.Equal(t, "cake -> loopy -> cake", idx.GetCircularReferences()[0].GenerateJourneyPath())
|
||||
}
|
||||
@@ -271,7 +272,7 @@ func TestExtractObject_DoubleRef_Circular_Fail(t *testing.T) {
|
||||
var cNode yaml.Node
|
||||
_ = yaml.Unmarshal([]byte(yml), &cNode)
|
||||
|
||||
_, err := ExtractObject[*pizza]("tags", &cNode, idx)
|
||||
_, err := ExtractObject[*pizza](context.Background(), "tags", &cNode, idx)
|
||||
assert.Error(t, err)
|
||||
}
|
||||
|
||||
@@ -300,7 +301,7 @@ func TestExtractObject_DoubleRef_Circular_Direct(t *testing.T) {
|
||||
var cNode yaml.Node
|
||||
_ = yaml.Unmarshal([]byte(yml), &cNode)
|
||||
|
||||
_, err := ExtractObject[*pizza]("tags", cNode.Content[0], idx)
|
||||
_, err := ExtractObject[*pizza](context.Background(), "tags", cNode.Content[0], idx)
|
||||
assert.Error(t, err)
|
||||
assert.Equal(t, "cake -> loopy -> cake", idx.GetCircularReferences()[0].GenerateJourneyPath())
|
||||
}
|
||||
@@ -330,7 +331,7 @@ func TestExtractObject_DoubleRef_Circular_Direct_Fail(t *testing.T) {
|
||||
var cNode yaml.Node
|
||||
_ = yaml.Unmarshal([]byte(yml), &cNode)
|
||||
|
||||
_, err := ExtractObject[*pizza]("tags", cNode.Content[0], idx)
|
||||
_, err := ExtractObject[*pizza](context.Background(), "tags", cNode.Content[0], idx)
|
||||
assert.Error(t, err)
|
||||
|
||||
}
|
||||
@@ -339,7 +340,7 @@ type test_borked struct {
|
||||
DontWork int
|
||||
}
|
||||
|
||||
func (t test_borked) Build(_, root *yaml.Node, idx *index.SpecIndex) error {
|
||||
func (t test_borked) Build(_ context.Context, _, root *yaml.Node, idx *index.SpecIndex) error {
|
||||
return fmt.Errorf("I am always going to fail, every thing")
|
||||
}
|
||||
|
||||
@@ -347,7 +348,7 @@ type test_noGood struct {
|
||||
DontWork int
|
||||
}
|
||||
|
||||
func (t *test_noGood) Build(_, root *yaml.Node, idx *index.SpecIndex) error {
|
||||
func (t *test_noGood) Build(_ context.Context, _, root *yaml.Node, idx *index.SpecIndex) error {
|
||||
return fmt.Errorf("I am always going to fail a core build")
|
||||
}
|
||||
|
||||
@@ -355,7 +356,7 @@ type test_almostGood struct {
|
||||
AlmostWork NodeReference[int]
|
||||
}
|
||||
|
||||
func (t *test_almostGood) Build(_, root *yaml.Node, idx *index.SpecIndex) error {
|
||||
func (t *test_almostGood) Build(_ context.Context, _, root *yaml.Node, idx *index.SpecIndex) error {
|
||||
return fmt.Errorf("I am always going to fail a build out")
|
||||
}
|
||||
|
||||
@@ -363,7 +364,7 @@ type test_Good struct {
|
||||
AlmostWork NodeReference[int]
|
||||
}
|
||||
|
||||
func (t *test_Good) Build(_, root *yaml.Node, idx *index.SpecIndex) error {
|
||||
func (t *test_Good) Build(_ context.Context, _, root *yaml.Node, idx *index.SpecIndex) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -383,7 +384,7 @@ func TestExtractObject_BadLowLevelModel(t *testing.T) {
|
||||
var cNode yaml.Node
|
||||
_ = yaml.Unmarshal([]byte(yml), &cNode)
|
||||
|
||||
_, err := ExtractObject[*test_noGood]("thing", &cNode, idx)
|
||||
_, err := ExtractObject[*test_noGood](context.Background(), "thing", &cNode, idx)
|
||||
assert.Error(t, err)
|
||||
|
||||
}
|
||||
@@ -404,7 +405,7 @@ func TestExtractObject_BadBuild(t *testing.T) {
|
||||
var cNode yaml.Node
|
||||
_ = yaml.Unmarshal([]byte(yml), &cNode)
|
||||
|
||||
_, err := ExtractObject[*test_almostGood]("thing", &cNode, idx)
|
||||
_, err := ExtractObject[*test_almostGood](context.Background(), "thing", &cNode, idx)
|
||||
assert.Error(t, err)
|
||||
|
||||
}
|
||||
@@ -425,7 +426,7 @@ func TestExtractObject_BadLabel(t *testing.T) {
|
||||
var cNode yaml.Node
|
||||
_ = yaml.Unmarshal([]byte(yml), &cNode)
|
||||
|
||||
res, err := ExtractObject[*test_almostGood]("ding", &cNode, idx)
|
||||
res, err := ExtractObject[*test_almostGood](context.Background(), "ding", &cNode, idx)
|
||||
assert.Nil(t, res.Value)
|
||||
assert.NoError(t, err)
|
||||
|
||||
@@ -458,7 +459,7 @@ func TestExtractObject_PathIsCircular(t *testing.T) {
|
||||
mErr = yaml.Unmarshal([]byte(yml), &rootNode)
|
||||
assert.NoError(t, mErr)
|
||||
|
||||
res, err := ExtractObject[*test_Good]("thing", &rootNode, idx)
|
||||
res, err := ExtractObject[*test_Good](context.Background(), "thing", &rootNode, idx)
|
||||
assert.NotNil(t, res.Value)
|
||||
assert.Error(t, err) // circular error would have been thrown.
|
||||
|
||||
@@ -494,7 +495,7 @@ func TestExtractObject_PathIsCircular_IgnoreErrors(t *testing.T) {
|
||||
mErr = yaml.Unmarshal([]byte(yml), &rootNode)
|
||||
assert.NoError(t, mErr)
|
||||
|
||||
res, err := ExtractObject[*test_Good]("thing", &rootNode, idx)
|
||||
res, err := ExtractObject[*test_Good](context.Background(), "thing", &rootNode, idx)
|
||||
assert.NotNil(t, res.Value)
|
||||
assert.NoError(t, err) // circular error would have been thrown, but we're ignoring them.
|
||||
|
||||
@@ -517,7 +518,7 @@ func TestExtractObjectRaw(t *testing.T) {
|
||||
var cNode yaml.Node
|
||||
_ = yaml.Unmarshal([]byte(yml), &cNode)
|
||||
|
||||
tag, err, _, _ := ExtractObjectRaw[*pizza](nil, cNode.Content[0], idx)
|
||||
tag, err, _, _ := ExtractObjectRaw[*pizza](context.Background(), nil, cNode.Content[0], idx)
|
||||
assert.NoError(t, err)
|
||||
assert.NotNil(t, tag)
|
||||
assert.Equal(t, "hello pizza", tag.Description.Value)
|
||||
@@ -540,7 +541,7 @@ func TestExtractObjectRaw_With_Ref(t *testing.T) {
|
||||
var cNode yaml.Node
|
||||
_ = yaml.Unmarshal([]byte(yml), &cNode)
|
||||
|
||||
tag, err, isRef, rv := ExtractObjectRaw[*pizza](nil, cNode.Content[0], idx)
|
||||
tag, err, isRef, rv := ExtractObjectRaw[*pizza](context.Background(), nil, cNode.Content[0], idx)
|
||||
assert.NoError(t, err)
|
||||
assert.NotNil(t, tag)
|
||||
assert.Equal(t, "hello", tag.Description.Value)
|
||||
@@ -570,7 +571,7 @@ func TestExtractObjectRaw_Ref_Circular(t *testing.T) {
|
||||
var cNode yaml.Node
|
||||
_ = yaml.Unmarshal([]byte(yml), &cNode)
|
||||
|
||||
tag, err, _, _ := ExtractObjectRaw[*pizza](nil, cNode.Content[0], idx)
|
||||
tag, err, _, _ := ExtractObjectRaw[*pizza](context.Background(), nil, cNode.Content[0], idx)
|
||||
assert.Error(t, err)
|
||||
assert.NotNil(t, tag)
|
||||
|
||||
@@ -592,7 +593,7 @@ func TestExtractObjectRaw_RefBroken(t *testing.T) {
|
||||
var cNode yaml.Node
|
||||
_ = yaml.Unmarshal([]byte(yml), &cNode)
|
||||
|
||||
tag, err, _, _ := ExtractObjectRaw[*pizza](nil, cNode.Content[0], idx)
|
||||
tag, err, _, _ := ExtractObjectRaw[*pizza](context.Background(), nil, cNode.Content[0], idx)
|
||||
assert.Error(t, err)
|
||||
assert.Nil(t, tag)
|
||||
|
||||
@@ -614,7 +615,7 @@ func TestExtractObjectRaw_Ref_NonBuildable(t *testing.T) {
|
||||
var cNode yaml.Node
|
||||
_ = yaml.Unmarshal([]byte(yml), &cNode)
|
||||
|
||||
_, err, _, _ := ExtractObjectRaw[*test_noGood](nil, cNode.Content[0], idx)
|
||||
_, err, _, _ := ExtractObjectRaw[*test_noGood](context.Background(), nil, cNode.Content[0], idx)
|
||||
assert.Error(t, err)
|
||||
|
||||
}
|
||||
@@ -635,7 +636,7 @@ func TestExtractObjectRaw_Ref_AlmostBuildable(t *testing.T) {
|
||||
var cNode yaml.Node
|
||||
_ = yaml.Unmarshal([]byte(yml), &cNode)
|
||||
|
||||
_, err, _, _ := ExtractObjectRaw[*test_almostGood](nil, cNode.Content[0], idx)
|
||||
_, err, _, _ := ExtractObjectRaw[*test_almostGood](context.Background(), nil, cNode.Content[0], idx)
|
||||
assert.Error(t, err)
|
||||
|
||||
}
|
||||
@@ -660,7 +661,7 @@ func TestExtractArray(t *testing.T) {
|
||||
var cNode yaml.Node
|
||||
_ = yaml.Unmarshal([]byte(yml), &cNode)
|
||||
|
||||
things, _, _, err := ExtractArray[*pizza]("things", cNode.Content[0], idx)
|
||||
things, _, _, err := ExtractArray[*pizza](context.Background(), "things", cNode.Content[0], idx)
|
||||
assert.NoError(t, err)
|
||||
assert.NotNil(t, things)
|
||||
assert.Equal(t, "one", things[0].Value.Description.Value)
|
||||
@@ -687,7 +688,7 @@ func TestExtractArray_Ref(t *testing.T) {
|
||||
var cNode yaml.Node
|
||||
_ = yaml.Unmarshal([]byte(yml), &cNode)
|
||||
|
||||
things, _, _, err := ExtractArray[*pizza]("things", cNode.Content[0], idx)
|
||||
things, _, _, err := ExtractArray[*pizza](context.Background(), "things", cNode.Content[0], idx)
|
||||
assert.NoError(t, err)
|
||||
assert.NotNil(t, things)
|
||||
assert.Equal(t, "one", things[0].Value.Description.Value)
|
||||
@@ -714,7 +715,7 @@ func TestExtractArray_Ref_Unbuildable(t *testing.T) {
|
||||
var cNode yaml.Node
|
||||
_ = yaml.Unmarshal([]byte(yml), &cNode)
|
||||
|
||||
things, _, _, err := ExtractArray[*test_noGood]("", cNode.Content[0], idx)
|
||||
things, _, _, err := ExtractArray[*test_noGood](context.Background(), "", cNode.Content[0], idx)
|
||||
assert.Error(t, err)
|
||||
assert.Len(t, things, 0)
|
||||
}
|
||||
@@ -742,7 +743,7 @@ func TestExtractArray_Ref_Circular(t *testing.T) {
|
||||
var cNode yaml.Node
|
||||
_ = yaml.Unmarshal([]byte(yml), &cNode)
|
||||
|
||||
things, _, _, err := ExtractArray[*test_Good]("", cNode.Content[0], idx)
|
||||
things, _, _, err := ExtractArray[*test_Good](context.Background(), "", cNode.Content[0], idx)
|
||||
assert.Error(t, err)
|
||||
assert.Len(t, things, 0)
|
||||
}
|
||||
@@ -770,7 +771,7 @@ func TestExtractArray_Ref_Bad(t *testing.T) {
|
||||
var cNode yaml.Node
|
||||
_ = yaml.Unmarshal([]byte(yml), &cNode)
|
||||
|
||||
things, _, _, err := ExtractArray[*test_Good]("", cNode.Content[0], idx)
|
||||
things, _, _, err := ExtractArray[*test_Good](context.Background(), "", cNode.Content[0], idx)
|
||||
assert.Error(t, err)
|
||||
assert.Len(t, things, 0)
|
||||
}
|
||||
@@ -799,7 +800,7 @@ func TestExtractArray_Ref_Nested(t *testing.T) {
|
||||
var cNode yaml.Node
|
||||
_ = yaml.Unmarshal([]byte(yml), &cNode)
|
||||
|
||||
things, _, _, err := ExtractArray[*test_Good]("limes", cNode.Content[0], idx)
|
||||
things, _, _, err := ExtractArray[*test_Good](context.Background(), "limes", cNode.Content[0], idx)
|
||||
assert.Error(t, err)
|
||||
assert.Len(t, things, 0)
|
||||
}
|
||||
@@ -828,7 +829,7 @@ func TestExtractArray_Ref_Nested_Circular(t *testing.T) {
|
||||
var cNode yaml.Node
|
||||
_ = yaml.Unmarshal([]byte(yml), &cNode)
|
||||
|
||||
things, _, _, err := ExtractArray[*test_Good]("limes", cNode.Content[0], idx)
|
||||
things, _, _, err := ExtractArray[*test_Good](context.Background(), "limes", cNode.Content[0], idx)
|
||||
assert.Error(t, err)
|
||||
assert.Len(t, things, 1)
|
||||
}
|
||||
@@ -855,7 +856,7 @@ func TestExtractArray_Ref_Nested_BadRef(t *testing.T) {
|
||||
var cNode yaml.Node
|
||||
e := yaml.Unmarshal([]byte(yml), &cNode)
|
||||
assert.NoError(t, e)
|
||||
things, _, _, err := ExtractArray[*test_Good]("limes", cNode.Content[0], idx)
|
||||
things, _, _, err := ExtractArray[*test_Good](context.Background(), "limes", cNode.Content[0], idx)
|
||||
assert.Error(t, err)
|
||||
assert.Len(t, things, 0)
|
||||
}
|
||||
@@ -884,7 +885,7 @@ func TestExtractArray_Ref_Nested_CircularFlat(t *testing.T) {
|
||||
var cNode yaml.Node
|
||||
e := yaml.Unmarshal([]byte(yml), &cNode)
|
||||
assert.NoError(t, e)
|
||||
things, _, _, err := ExtractArray[*test_Good]("limes", cNode.Content[0], idx)
|
||||
things, _, _, err := ExtractArray[*test_Good](context.Background(), "limes", cNode.Content[0], idx)
|
||||
assert.Error(t, err)
|
||||
assert.Len(t, things, 0)
|
||||
}
|
||||
@@ -906,7 +907,7 @@ func TestExtractArray_BadBuild(t *testing.T) {
|
||||
var cNode yaml.Node
|
||||
e := yaml.Unmarshal([]byte(yml), &cNode)
|
||||
assert.NoError(t, e)
|
||||
things, _, _, err := ExtractArray[*test_noGood]("limes", cNode.Content[0], idx)
|
||||
things, _, _, err := ExtractArray[*test_noGood](context.Background(), "limes", cNode.Content[0], idx)
|
||||
assert.Error(t, err)
|
||||
assert.Len(t, things, 0)
|
||||
}
|
||||
@@ -965,7 +966,7 @@ one:
|
||||
e := yaml.Unmarshal([]byte(yml), &cNode)
|
||||
assert.NoError(t, e)
|
||||
|
||||
things, err := ExtractMapNoLookup[*test_Good](cNode.Content[0], idx)
|
||||
things, err := ExtractMapNoLookup[*test_Good](context.Background(), cNode.Content[0], idx)
|
||||
assert.NoError(t, err)
|
||||
assert.Len(t, things, 1)
|
||||
|
||||
@@ -988,7 +989,7 @@ one:
|
||||
e := yaml.Unmarshal([]byte(yml), &cNode)
|
||||
assert.NoError(t, e)
|
||||
|
||||
things, err := ExtractMapNoLookupExtensions[*test_Good](cNode.Content[0], idx, true)
|
||||
things, err := ExtractMapNoLookupExtensions[*test_Good](context.Background(), cNode.Content[0], idx, true)
|
||||
assert.NoError(t, err)
|
||||
assert.Len(t, things, 2)
|
||||
|
||||
@@ -1021,7 +1022,7 @@ one:
|
||||
e := yaml.Unmarshal([]byte(yml), &cNode)
|
||||
assert.NoError(t, e)
|
||||
|
||||
things, err := ExtractMapNoLookupExtensions[*test_Good](cNode.Content[0], idx, true)
|
||||
things, err := ExtractMapNoLookupExtensions[*test_Good](context.Background(), cNode.Content[0], idx, true)
|
||||
assert.NoError(t, err)
|
||||
assert.Len(t, things, 4)
|
||||
|
||||
@@ -1044,7 +1045,7 @@ one:
|
||||
e := yaml.Unmarshal([]byte(yml), &cNode)
|
||||
assert.NoError(t, e)
|
||||
|
||||
things, err := ExtractMapNoLookupExtensions[*test_Good](cNode.Content[0], idx, false)
|
||||
things, err := ExtractMapNoLookupExtensions[*test_Good](context.Background(), cNode.Content[0], idx, false)
|
||||
assert.NoError(t, err)
|
||||
assert.Len(t, things, 1)
|
||||
|
||||
@@ -1070,7 +1071,7 @@ one:
|
||||
e := yaml.Unmarshal([]byte(yml), &cNode)
|
||||
assert.NoError(t, e)
|
||||
|
||||
things, _, _, err := ExtractMapExtensions[*test_Good]("one", cNode.Content[0], idx, true)
|
||||
things, _, _, err := ExtractMapExtensions[*test_Good](context.Background(), "one", cNode.Content[0], idx, true)
|
||||
assert.NoError(t, err)
|
||||
assert.Len(t, things, 1)
|
||||
}
|
||||
@@ -1092,7 +1093,7 @@ one:
|
||||
e := yaml.Unmarshal([]byte(yml), &cNode)
|
||||
assert.NoError(t, e)
|
||||
|
||||
things, _, _, err := ExtractMapExtensions[*test_Good]("one", cNode.Content[0], idx, false)
|
||||
things, _, _, err := ExtractMapExtensions[*test_Good](context.Background(), "one", cNode.Content[0], idx, false)
|
||||
assert.NoError(t, err)
|
||||
assert.Len(t, things, 0)
|
||||
}
|
||||
@@ -1117,7 +1118,7 @@ one:
|
||||
e := yaml.Unmarshal([]byte(yml), &cNode)
|
||||
assert.NoError(t, e)
|
||||
|
||||
things, err := ExtractMapNoLookup[*test_Good](cNode.Content[0], idx)
|
||||
things, err := ExtractMapNoLookup[*test_Good](context.Background(), cNode.Content[0], idx)
|
||||
assert.NoError(t, err)
|
||||
assert.Len(t, things, 1)
|
||||
|
||||
@@ -1143,7 +1144,7 @@ one:
|
||||
e := yaml.Unmarshal([]byte(yml), &cNode)
|
||||
assert.NoError(t, e)
|
||||
|
||||
things, err := ExtractMapNoLookup[*test_Good](cNode.Content[0], idx)
|
||||
things, err := ExtractMapNoLookup[*test_Good](context.Background(), cNode.Content[0], idx)
|
||||
assert.Error(t, err)
|
||||
assert.Len(t, things, 0)
|
||||
|
||||
@@ -1175,7 +1176,7 @@ one:
|
||||
e := yaml.Unmarshal([]byte(yml), &cNode)
|
||||
assert.NoError(t, e)
|
||||
|
||||
things, err := ExtractMapNoLookup[*test_Good](cNode.Content[0], idx)
|
||||
things, err := ExtractMapNoLookup[*test_Good](context.Background(), cNode.Content[0], idx)
|
||||
assert.Error(t, err)
|
||||
assert.Len(t, things, 1)
|
||||
|
||||
@@ -1201,7 +1202,7 @@ hello:
|
||||
e := yaml.Unmarshal([]byte(yml), &cNode)
|
||||
assert.NoError(t, e)
|
||||
|
||||
things, err := ExtractMapNoLookup[*test_noGood](cNode.Content[0], idx)
|
||||
things, err := ExtractMapNoLookup[*test_noGood](context.Background(), cNode.Content[0], idx)
|
||||
assert.Error(t, err)
|
||||
assert.Len(t, things, 0)
|
||||
|
||||
@@ -1227,7 +1228,7 @@ one:
|
||||
e := yaml.Unmarshal([]byte(yml), &cNode)
|
||||
assert.NoError(t, e)
|
||||
|
||||
things, err := ExtractMapNoLookup[*test_almostGood](cNode.Content[0], idx)
|
||||
things, err := ExtractMapNoLookup[*test_almostGood](context.Background(), cNode.Content[0], idx)
|
||||
assert.Error(t, err)
|
||||
assert.Len(t, things, 0)
|
||||
|
||||
@@ -1250,7 +1251,7 @@ one:
|
||||
e := yaml.Unmarshal([]byte(yml), &cNode)
|
||||
assert.NoError(t, e)
|
||||
|
||||
things, _, _, err := ExtractMap[*test_Good]("one", cNode.Content[0], idx)
|
||||
things, _, _, err := ExtractMap[*test_Good](context.Background(), "one", cNode.Content[0], idx)
|
||||
assert.NoError(t, err)
|
||||
assert.Len(t, things, 1)
|
||||
|
||||
@@ -1277,7 +1278,7 @@ one:
|
||||
e := yaml.Unmarshal([]byte(yml), &cNode)
|
||||
assert.NoError(t, e)
|
||||
|
||||
things, _, _, err := ExtractMap[*test_Good]("one", cNode.Content[0], idx)
|
||||
things, _, _, err := ExtractMap[*test_Good](context.Background(), "one", cNode.Content[0], idx)
|
||||
assert.NoError(t, err)
|
||||
assert.Len(t, things, 1)
|
||||
|
||||
@@ -1307,7 +1308,7 @@ func TestExtractMapFlat_DoubleRef(t *testing.T) {
|
||||
e := yaml.Unmarshal([]byte(yml), &cNode)
|
||||
assert.NoError(t, e)
|
||||
|
||||
things, _, _, err := ExtractMap[*test_Good]("one", cNode.Content[0], idx)
|
||||
things, _, _, err := ExtractMap[*test_Good](context.Background(), "one", cNode.Content[0], idx)
|
||||
assert.NoError(t, err)
|
||||
assert.Len(t, things, 1)
|
||||
|
||||
@@ -1337,7 +1338,7 @@ func TestExtractMapFlat_DoubleRef_Error(t *testing.T) {
|
||||
e := yaml.Unmarshal([]byte(yml), &cNode)
|
||||
assert.NoError(t, e)
|
||||
|
||||
things, _, _, err := ExtractMap[*test_almostGood]("one", cNode.Content[0], idx)
|
||||
things, _, _, err := ExtractMap[*test_almostGood](context.Background(), "one", cNode.Content[0], idx)
|
||||
assert.Error(t, err)
|
||||
assert.Len(t, things, 0)
|
||||
|
||||
@@ -1364,7 +1365,7 @@ func TestExtractMapFlat_DoubleRef_Error_NotFound(t *testing.T) {
|
||||
e := yaml.Unmarshal([]byte(yml), &cNode)
|
||||
assert.NoError(t, e)
|
||||
|
||||
things, _, _, err := ExtractMap[*test_almostGood]("one", cNode.Content[0], idx)
|
||||
things, _, _, err := ExtractMap[*test_almostGood](context.Background(), "one", cNode.Content[0], idx)
|
||||
assert.Error(t, err)
|
||||
assert.Len(t, things, 0)
|
||||
|
||||
@@ -1396,7 +1397,7 @@ func TestExtractMapFlat_DoubleRef_Circles(t *testing.T) {
|
||||
e := yaml.Unmarshal([]byte(yml), &cNode)
|
||||
assert.NoError(t, e)
|
||||
|
||||
things, _, _, err := ExtractMap[*test_Good]("one", cNode.Content[0], idx)
|
||||
things, _, _, err := ExtractMap[*test_Good](context.Background(), "one", cNode.Content[0], idx)
|
||||
assert.Error(t, err)
|
||||
assert.Len(t, things, 1)
|
||||
|
||||
@@ -1423,7 +1424,7 @@ func TestExtractMapFlat_Ref_Error(t *testing.T) {
|
||||
e := yaml.Unmarshal([]byte(yml), &cNode)
|
||||
assert.NoError(t, e)
|
||||
|
||||
things, _, _, err := ExtractMap[*test_almostGood]("one", cNode.Content[0], idx)
|
||||
things, _, _, err := ExtractMap[*test_almostGood](context.Background(), "one", cNode.Content[0], idx)
|
||||
assert.Error(t, err)
|
||||
assert.Len(t, things, 0)
|
||||
|
||||
@@ -1453,7 +1454,7 @@ func TestExtractMapFlat_Ref_Circ_Error(t *testing.T) {
|
||||
e := yaml.Unmarshal([]byte(yml), &cNode)
|
||||
assert.NoError(t, e)
|
||||
|
||||
things, _, _, err := ExtractMap[*test_Good]("one", cNode.Content[0], idx)
|
||||
things, _, _, err := ExtractMap[*test_Good](context.Background(), "one", cNode.Content[0], idx)
|
||||
assert.Error(t, err)
|
||||
assert.Len(t, things, 1)
|
||||
}
|
||||
@@ -1483,7 +1484,7 @@ func TestExtractMapFlat_Ref_Nested_Circ_Error(t *testing.T) {
|
||||
e := yaml.Unmarshal([]byte(yml), &cNode)
|
||||
assert.NoError(t, e)
|
||||
|
||||
things, _, _, err := ExtractMap[*test_Good]("one", cNode.Content[0], idx)
|
||||
things, _, _, err := ExtractMap[*test_Good](context.Background(), "one", cNode.Content[0], idx)
|
||||
assert.Error(t, err)
|
||||
assert.Len(t, things, 1)
|
||||
}
|
||||
@@ -1509,7 +1510,7 @@ func TestExtractMapFlat_Ref_Nested_Error(t *testing.T) {
|
||||
e := yaml.Unmarshal([]byte(yml), &cNode)
|
||||
assert.NoError(t, e)
|
||||
|
||||
things, _, _, err := ExtractMap[*test_Good]("one", cNode.Content[0], idx)
|
||||
things, _, _, err := ExtractMap[*test_Good](context.Background(), "one", cNode.Content[0], idx)
|
||||
assert.Error(t, err)
|
||||
assert.Len(t, things, 0)
|
||||
}
|
||||
@@ -1535,7 +1536,7 @@ func TestExtractMapFlat_BadKey_Ref_Nested_Error(t *testing.T) {
|
||||
e := yaml.Unmarshal([]byte(yml), &cNode)
|
||||
assert.NoError(t, e)
|
||||
|
||||
things, _, _, err := ExtractMap[*test_Good]("not-even-there", cNode.Content[0], idx)
|
||||
things, _, _, err := ExtractMap[*test_Good](context.Background(), "not-even-there", cNode.Content[0], idx)
|
||||
assert.NoError(t, err)
|
||||
assert.Len(t, things, 0)
|
||||
}
|
||||
@@ -1564,7 +1565,7 @@ func TestExtractMapFlat_Ref_Bad(t *testing.T) {
|
||||
e := yaml.Unmarshal([]byte(yml), &cNode)
|
||||
assert.NoError(t, e)
|
||||
|
||||
things, _, _, err := ExtractMap[*test_Good]("one", cNode.Content[0], idx)
|
||||
things, _, _, err := ExtractMap[*test_Good](context.Background(), "one", cNode.Content[0], idx)
|
||||
assert.Error(t, err)
|
||||
assert.Len(t, things, 0)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user