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 v3
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 TestLink_Build(t *testing.T) {
yml := `operationRef: '#/someref'
operationId: someId
parameters:
@@ -41,9 +42,9 @@ x-linky: slinky
assert.Equal(t, "someId", n.OperationId.Value)
assert.Equal(t, "this is a link object.", n.Description.Value)
ext := n.FindExtension("x-linky")
assert.NotNil(t, ext)
assert.Equal(t, "slinky", ext.Value)
var xLinky string
_ = n.FindExtension("x-linky").Value.Decode(&xLinky)
assert.Equal(t, "slinky", xLinky)
param1 := n.FindParameter("param1")
assert.Equal(t, "something", param1.Value)
@@ -52,12 +53,10 @@ x-linky: slinky
assert.NotNil(t, n.Server.Value)
assert.Equal(t, "https://pb33f.io", n.Server.Value.URL.Value)
assert.Len(t, n.GetExtensions(), 1)
assert.Equal(t, 1, orderedmap.Len(n.GetExtensions()))
}
func TestLink_Build_Fail(t *testing.T) {
yml := `operationRef: '#/someref'
operationId: someId
parameters:
@@ -78,11 +77,9 @@ server:
err = n.Build(context.Background(), nil, idxNode.Content[0], idx)
assert.Error(t, err)
}
func TestLink_Hash(t *testing.T) {
yml := `operationRef: something
operationId: someWhere
parameters:
@@ -123,5 +120,4 @@ server:
// hash
assert.Equal(t, n.Hash(), n2.Hash())
}