mirror of
https://github.com/LukeHagar/libopenapi.git
synced 2025-12-09 20:47:44 +00:00
Swagger v2 high model at 100% coverage.
This commit is contained in:
37
datamodel/high/base/external_doc_test.go
Normal file
37
datamodel/high/base/external_doc_test.go
Normal file
@@ -0,0 +1,37 @@
|
||||
// Copyright 2022 Princess B33f Heavy Industries / Dave Shanley
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
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"
|
||||
)
|
||||
|
||||
func TestNewExternalDoc(t *testing.T) {
|
||||
|
||||
var cNode yaml.Node
|
||||
|
||||
yml := `description: hack code
|
||||
url: https://pb33f.io
|
||||
x-hack: code`
|
||||
|
||||
_ = yaml.Unmarshal([]byte(yml), &cNode)
|
||||
|
||||
var lowExt lowbase.ExternalDoc
|
||||
_ = lowmodel.BuildModel(&cNode, &lowExt)
|
||||
|
||||
_ = lowExt.Build(cNode.Content[0], nil)
|
||||
|
||||
highExt := NewExternalDoc(&lowExt)
|
||||
|
||||
assert.Equal(t, "hack code", highExt.Description)
|
||||
assert.Equal(t, "https://pb33f.io", highExt.URL)
|
||||
assert.Equal(t, "code", highExt.Extensions["x-hack"])
|
||||
|
||||
wentLow := highExt.GoLow()
|
||||
assert.Equal(t, 2, wentLow.URL.ValueNode.Line)
|
||||
}
|
||||
Reference in New Issue
Block a user