mirror of
https://github.com/LukeHagar/libopenapi.git
synced 2025-12-06 04:20:11 +00:00
Added some more tests to bump coverage back up.
Signed-off-by: Dave Shanley <dave@quobix.com>
This commit is contained in:
@@ -1004,6 +1004,39 @@ one:
|
||||
}
|
||||
}
|
||||
|
||||
func TestExtractMap_NoLookupWithExtensions_UsingMerge(t *testing.T) {
|
||||
|
||||
yml := `components:`
|
||||
|
||||
var idxNode yaml.Node
|
||||
mErr := yaml.Unmarshal([]byte(yml), &idxNode)
|
||||
assert.NoError(t, mErr)
|
||||
idx := index.NewSpecIndex(&idxNode)
|
||||
|
||||
yml = `x-yeah: &yeah
|
||||
night: fun
|
||||
x-hey: you
|
||||
one:
|
||||
x-choo: choo
|
||||
<<: *yeah`
|
||||
|
||||
var cNode yaml.Node
|
||||
e := yaml.Unmarshal([]byte(yml), &cNode)
|
||||
assert.NoError(t, e)
|
||||
|
||||
things, err := ExtractMapNoLookupExtensions[*test_Good](cNode.Content[0], idx, true)
|
||||
assert.NoError(t, err)
|
||||
assert.Len(t, things, 3)
|
||||
|
||||
for k, v := range things {
|
||||
if k.Value == "x-hey" || k.Value == "x-yeah" || k.Value == "night" || k.Value == "<<" {
|
||||
continue
|
||||
}
|
||||
assert.Equal(t, "one", k.Value)
|
||||
assert.Len(t, v.ValueNode.Content, 6)
|
||||
}
|
||||
}
|
||||
|
||||
func TestExtractMap_NoLookupWithoutExtensions(t *testing.T) {
|
||||
|
||||
yml := `components:`
|
||||
|
||||
@@ -802,6 +802,33 @@ thangs: *anchorA`
|
||||
|
||||
}
|
||||
|
||||
func TestNodeAlias_Nil(t *testing.T) {
|
||||
ref := NodeAlias(nil)
|
||||
assert.Nil(t, ref)
|
||||
}
|
||||
|
||||
func TestNodeAlias_IsNodeAlias_Nil(t *testing.T) {
|
||||
|
||||
_, isAlias := IsNodeAlias(nil)
|
||||
assert.False(t, isAlias)
|
||||
|
||||
}
|
||||
|
||||
func TestNodeAlias_IsNodeAlias_False(t *testing.T) {
|
||||
|
||||
yml := `things:
|
||||
- Stuff
|
||||
- Junk
|
||||
thangs: none`
|
||||
|
||||
var node yaml.Node
|
||||
_ = yaml.Unmarshal([]byte(yml), &node)
|
||||
|
||||
_, isAlias := IsNodeAlias(node.Content[0].Content[3])
|
||||
assert.False(t, isAlias)
|
||||
|
||||
}
|
||||
|
||||
func TestCheckForMergeNodes(t *testing.T) {
|
||||
|
||||
yml := `x-common-definitions:
|
||||
@@ -850,6 +877,15 @@ func TestIsNodeRefValue_False(t *testing.T) {
|
||||
assert.Empty(t, val)
|
||||
}
|
||||
|
||||
func TestIsNodeRefValue_Nil(t *testing.T) {
|
||||
|
||||
ref, node, val := IsNodeRefValue(nil)
|
||||
|
||||
assert.False(t, ref)
|
||||
assert.Nil(t, node)
|
||||
assert.Empty(t, val)
|
||||
}
|
||||
|
||||
func TestCheckEnumForDuplicates_Success(t *testing.T) {
|
||||
yml := "- yes\n- no\n- crisps"
|
||||
var rootNode yaml.Node
|
||||
|
||||
Reference in New Issue
Block a user