fix: continued moving everything to orderedmaps plus cleaned up most the tests

This commit is contained in:
Tristan Cartledge
2023-12-01 17:37:07 +00:00
parent 0f3d0cb28f
commit a4ad09aab3
169 changed files with 3435 additions and 3764 deletions

View File

@@ -5,15 +5,16 @@ package base
import (
"context"
"testing"
"github.com/pb33f/libopenapi/datamodel/low"
"github.com/pb33f/libopenapi/index"
"github.com/pb33f/libopenapi/orderedmap"
"github.com/stretchr/testify/assert"
"gopkg.in/yaml.v3"
"testing"
)
func TestExternalDoc_FindExtension(t *testing.T) {
yml := `x-fish: cake`
var idxNode yaml.Node
@@ -26,12 +27,14 @@ func TestExternalDoc_FindExtension(t *testing.T) {
err = n.Build(context.Background(), nil, idxNode.Content[0], idx)
assert.NoError(t, err)
assert.Equal(t, "cake", n.FindExtension("x-fish").Value)
var xFish string
_ = n.FindExtension("x-fish").Value.Decode(&xFish)
assert.Equal(t, "cake", xFish)
}
func TestExternalDoc_Build(t *testing.T) {
yml := `url: https://pb33f.io
description: the ranch
x-b33f: princess`
@@ -49,14 +52,13 @@ x-b33f: princess`
assert.NoError(t, err)
assert.Equal(t, "https://pb33f.io", n.URL.Value)
assert.Equal(t, "the ranch", n.Description.Value)
ext := n.FindExtension("x-b33f")
assert.NotNil(t, ext)
assert.Equal(t, "princess", ext.Value)
var xB33f string
_ = n.FindExtension("x-b33f").Value.Decode(&xB33f)
assert.Equal(t, "princess", xB33f)
}
func TestExternalDoc_Hash(t *testing.T) {
left := `url: https://pb33f.io
description: the ranch
x-b33f: princess`
@@ -78,5 +80,5 @@ description: the ranch`
_ = rDoc.Build(context.Background(), nil, rNode.Content[0], nil)
assert.Equal(t, lDoc.Hash(), rDoc.Hash())
assert.Len(t, lDoc.GetExtensions(), 1)
assert.Equal(t, 1, orderedmap.Len(lDoc.GetExtensions()))
}