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

@@ -9,10 +9,14 @@ import (
"github.com/pb33f/libopenapi/datamodel/high/base"
"github.com/pb33f/libopenapi/orderedmap"
"github.com/pb33f/libopenapi/utils"
"github.com/stretchr/testify/assert"
"gopkg.in/yaml.v3"
)
func TestParameter_MarshalYAML(t *testing.T) {
ext := orderedmap.New[string, *yaml.Node]()
ext.Set("x-burgers", utils.CreateStringNode("why not?"))
explode := true
param := Parameter{
@@ -23,11 +27,11 @@ func TestParameter_MarshalYAML(t *testing.T) {
Style: "simple",
Explode: &explode,
AllowReserved: true,
Example: "example",
Example: utils.CreateStringNode("example"),
Examples: orderedmap.ToOrderedMap(map[string]*base.Example{
"example": {Value: "example"},
"example": {Value: utils.CreateStringNode("example")},
}),
Extensions: map[string]interface{}{"x-burgers": "why not?"},
Extensions: ext,
}
rend, _ := param.Render()
@@ -49,6 +53,8 @@ x-burgers: why not?`
}
func TestParameter_MarshalYAMLInline(t *testing.T) {
ext := orderedmap.New[string, *yaml.Node]()
ext.Set("x-burgers", utils.CreateStringNode("why not?"))
explode := true
param := Parameter{
@@ -59,11 +65,11 @@ func TestParameter_MarshalYAMLInline(t *testing.T) {
Style: "simple",
Explode: &explode,
AllowReserved: true,
Example: "example",
Example: utils.CreateStringNode("example"),
Examples: orderedmap.ToOrderedMap(map[string]*base.Example{
"example": {Value: "example"},
"example": {Value: utils.CreateStringNode("example")},
}),
Extensions: map[string]interface{}{"x-burgers": "why not?"},
Extensions: ext,
}
rend, _ := param.RenderInline()
@@ -85,7 +91,6 @@ x-burgers: why not?`
}
func TestParameter_IsExploded(t *testing.T) {
explode := true
param := Parameter{
Explode: &explode,
@@ -106,7 +111,6 @@ func TestParameter_IsExploded(t *testing.T) {
}
func TestParameter_IsDefaultFormEncoding(t *testing.T) {
param := Parameter{}
assert.True(t, param.IsDefaultFormEncoding())
@@ -133,7 +137,6 @@ func TestParameter_IsDefaultFormEncoding(t *testing.T) {
}
func TestParameter_IsDefaultHeaderEncoding(t *testing.T) {
param := Parameter{}
assert.True(t, param.IsDefaultHeaderEncoding())
@@ -163,8 +166,6 @@ func TestParameter_IsDefaultHeaderEncoding(t *testing.T) {
}
func TestParameter_IsDefaultPathEncoding(t *testing.T) {
param := Parameter{}
assert.True(t, param.IsDefaultPathEncoding())
}