mirror of
https://github.com/LukeHagar/libopenapi.git
synced 2025-12-06 12:37:49 +00:00
Added support for unevaluatedProperties as Schema and bool #118
Also ran `gofmt` across the entire project. Things need cleaning up. Signed-off-by: Dave Shanley <dave@quobix.com>
This commit is contained in:
@@ -4,56 +4,56 @@
|
||||
package base
|
||||
|
||||
import (
|
||||
lowmodel "github.com/pb33f/libopenapi/datamodel/low"
|
||||
lowbase "github.com/pb33f/libopenapi/datamodel/low/base"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"gopkg.in/yaml.v3"
|
||||
"testing"
|
||||
lowmodel "github.com/pb33f/libopenapi/datamodel/low"
|
||||
lowbase "github.com/pb33f/libopenapi/datamodel/low/base"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"gopkg.in/yaml.v3"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestLicense_Render(t *testing.T) {
|
||||
|
||||
highL := &License{Name: "MIT", URL: "https://pb33f.io"}
|
||||
dat, _ := highL.Render()
|
||||
highL := &License{Name: "MIT", URL: "https://pb33f.io"}
|
||||
dat, _ := highL.Render()
|
||||
|
||||
// unmarshal yaml into a *yaml.Node instance
|
||||
var cNode yaml.Node
|
||||
_ = yaml.Unmarshal(dat, &cNode)
|
||||
// unmarshal yaml into a *yaml.Node instance
|
||||
var cNode yaml.Node
|
||||
_ = yaml.Unmarshal(dat, &cNode)
|
||||
|
||||
// build low
|
||||
var lowLicense lowbase.License
|
||||
_ = lowmodel.BuildModel(cNode.Content[0], &lowLicense)
|
||||
// build low
|
||||
var lowLicense lowbase.License
|
||||
_ = lowmodel.BuildModel(cNode.Content[0], &lowLicense)
|
||||
|
||||
// build high
|
||||
highLicense := NewLicense(&lowLicense)
|
||||
// build high
|
||||
highLicense := NewLicense(&lowLicense)
|
||||
|
||||
assert.Equal(t, "MIT", highLicense.Name)
|
||||
assert.Equal(t, "https://pb33f.io", highLicense.URL)
|
||||
assert.Equal(t, "MIT", highLicense.Name)
|
||||
assert.Equal(t, "https://pb33f.io", highLicense.URL)
|
||||
|
||||
}
|
||||
|
||||
func TestLicense_RenderEqual(t *testing.T) {
|
||||
|
||||
yml := `name: MIT
|
||||
yml := `name: MIT
|
||||
url: https://pb33f.io/not-real
|
||||
`
|
||||
// unmarshal yaml into a *yaml.Node instance
|
||||
var cNode yaml.Node
|
||||
_ = yaml.Unmarshal([]byte(yml), &cNode)
|
||||
// unmarshal yaml into a *yaml.Node instance
|
||||
var cNode yaml.Node
|
||||
_ = yaml.Unmarshal([]byte(yml), &cNode)
|
||||
|
||||
// build low
|
||||
var lowLicense lowbase.License
|
||||
_ = lowmodel.BuildModel(cNode.Content[0], &lowLicense)
|
||||
_ = lowLicense.Build(cNode.Content[0], nil)
|
||||
// build low
|
||||
var lowLicense lowbase.License
|
||||
_ = lowmodel.BuildModel(cNode.Content[0], &lowLicense)
|
||||
_ = lowLicense.Build(cNode.Content[0], nil)
|
||||
|
||||
// build high
|
||||
highLicense := NewLicense(&lowLicense)
|
||||
// build high
|
||||
highLicense := NewLicense(&lowLicense)
|
||||
|
||||
assert.Equal(t, "MIT", highLicense.Name)
|
||||
assert.Equal(t, "https://pb33f.io/not-real", highLicense.URL)
|
||||
assert.Equal(t, "MIT", highLicense.Name)
|
||||
assert.Equal(t, "https://pb33f.io/not-real", highLicense.URL)
|
||||
|
||||
// re-render and ensure everything is in the same order as before.
|
||||
bytes, _ := highLicense.Render()
|
||||
assert.Equal(t, yml, string(bytes))
|
||||
// re-render and ensure everything is in the same order as before.
|
||||
bytes, _ := highLicense.Render()
|
||||
assert.Equal(t, yml, string(bytes))
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user