Files
libopenapi/datamodel/low/base/discriminator_test.go
Dave Shanley 68743113ed Refactoring core structure of datamodel to accomodate v2 model.
There is a lot of overlap on these models, to create a much more sensible design, a new 'base' package has been added which contains shared models that both versions make use of.
2022-09-01 08:53:16 -04:00

29 lines
656 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 TestDiscriminator_FindMappingValue(t *testing.T) {
yml := `propertyName: freshCakes
mapping:
something: nothing`
var idxNode yaml.Node
mErr := yaml.Unmarshal([]byte(yml), &idxNode)
assert.NoError(t, mErr)
var n Discriminator
err := low.BuildModel(&idxNode, &n)
assert.NoError(t, err)
assert.Equal(t, "nothing", n.FindMappingValue("something").Value)
assert.Nil(t, n.FindMappingValue("freshCakes"))
}