mirror of
https://github.com/LukeHagar/libopenapi.git
synced 2025-12-09 20:47:44 +00:00
This is a large update, I realized that extensions are not being hashed correctly, and because I have the same code everywhere, it means running back through the stack and cleaning up the invalid code that will break if multiple extensions are used in different positions in the raw spec. At the same time, I realized that the v2 model has the same primitive/enum issues that are part cleaned up in v3. This is a breaking changhe because enums are now []any and not []string, as well as primitives for bool, int etc are all pointers now instead of the copied values. This will break any consumers.
34 lines
707 B
Go
34 lines
707 B
Go
// Copyright 2022 Princess B33f Heavy Industries / Dave Shanley
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
package base
|
|
|
|
import (
|
|
"github.com/pb33f/libopenapi/datamodel/low"
|
|
"github.com/stretchr/testify/assert"
|
|
"gopkg.in/yaml.v3"
|
|
"testing"
|
|
)
|
|
|
|
func TestLicense_Hash(t *testing.T) {
|
|
|
|
left := `url: https://pb33f.io
|
|
description: the ranch`
|
|
|
|
right := `url: https://pb33f.io
|
|
description: the ranch`
|
|
|
|
var lNode, rNode yaml.Node
|
|
_ = yaml.Unmarshal([]byte(left), &lNode)
|
|
_ = yaml.Unmarshal([]byte(right), &rNode)
|
|
|
|
// create low level objects
|
|
var lDoc License
|
|
var rDoc License
|
|
_ = low.BuildModel(lNode.Content[0], &lDoc)
|
|
_ = low.BuildModel(rNode.Content[0], &rDoc)
|
|
|
|
assert.Equal(t, lDoc.Hash(), rDoc.Hash())
|
|
|
|
}
|