mirror of
https://github.com/LukeHagar/libopenapi.git
synced 2025-12-10 04:20:24 +00:00
Fix compare different node tag
This commit is contained in:
committed by
Dave Shanley
parent
fc7da1d38d
commit
d6031b5440
@@ -4,12 +4,14 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"gopkg.in/yaml.v3"
|
||||
|
||||
"github.com/pb33f/libopenapi/datamodel/low"
|
||||
"github.com/pb33f/libopenapi/datamodel/low/base"
|
||||
v3 "github.com/pb33f/libopenapi/datamodel/low/v3"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"gopkg.in/yaml.v3"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestCompareExamples_SummaryModified(t *testing.T) {
|
||||
@@ -196,3 +198,27 @@ func TestCompareExamples_Identical(t *testing.T) {
|
||||
extChanges := CompareExamples(&lDoc, &rDoc)
|
||||
assert.Nil(t, extChanges)
|
||||
}
|
||||
|
||||
func TestCompareExamples_Date(t *testing.T) {
|
||||
left := `value:
|
||||
date: 2022-12-29`
|
||||
|
||||
right := `value:
|
||||
date: "2022-12-29"`
|
||||
|
||||
var lNode, rNode yaml.Node
|
||||
_ = yaml.Unmarshal([]byte(left), &lNode)
|
||||
_ = yaml.Unmarshal([]byte(right), &rNode)
|
||||
|
||||
// create low level objects
|
||||
var lDoc base.Example
|
||||
var rDoc base.Example
|
||||
_ = low.BuildModel(lNode.Content[0], &lDoc)
|
||||
_ = low.BuildModel(rNode.Content[0], &rDoc)
|
||||
_ = lDoc.Build(lNode.Content[0], nil)
|
||||
_ = rDoc.Build(rNode.Content[0], nil)
|
||||
|
||||
changes := CompareExamples(&lDoc, &rDoc)
|
||||
|
||||
assert.Equal(t, 1, changes.TotalChanges())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user