mirror of
https://github.com/LukeHagar/libopenapi.git
synced 2025-12-09 12:37:49 +00:00
A massive test update to bring everything inlne with the new Buildable signature.
All tests in index and datamodel now pass. The rolodex fixes all the things. Signed-off-by: quobix <dave@quobix.com>
This commit is contained in:
@@ -4,6 +4,7 @@
|
||||
package v2
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/pb33f/libopenapi/datamodel/low"
|
||||
"github.com/pb33f/libopenapi/datamodel/low/base"
|
||||
"github.com/pb33f/libopenapi/index"
|
||||
@@ -25,7 +26,7 @@ func TestParameter_Build(t *testing.T) {
|
||||
err := low.BuildModel(&idxNode, &n)
|
||||
assert.NoError(t, err)
|
||||
|
||||
err = n.Build(nil, idxNode.Content[0], idx)
|
||||
err = n.Build(context.Background(), nil, idxNode.Content[0], idx)
|
||||
assert.Error(t, err)
|
||||
|
||||
}
|
||||
@@ -44,7 +45,7 @@ func TestParameter_Build_Items(t *testing.T) {
|
||||
err := low.BuildModel(&idxNode, &n)
|
||||
assert.NoError(t, err)
|
||||
|
||||
err = n.Build(nil, idxNode.Content[0], idx)
|
||||
err = n.Build(context.Background(), nil, idxNode.Content[0], idx)
|
||||
assert.Error(t, err)
|
||||
|
||||
}
|
||||
@@ -63,7 +64,7 @@ func TestParameter_DefaultSlice(t *testing.T) {
|
||||
var n Parameter
|
||||
_ = low.BuildModel(&idxNode, &n)
|
||||
|
||||
_ = n.Build(nil, idxNode.Content[0], idx)
|
||||
_ = n.Build(context.Background(), nil, idxNode.Content[0], idx)
|
||||
assert.Len(t, n.Default.Value.([]any), 3)
|
||||
}
|
||||
|
||||
@@ -80,7 +81,7 @@ func TestParameter_DefaultMap(t *testing.T) {
|
||||
var n Parameter
|
||||
_ = low.BuildModel(&idxNode, &n)
|
||||
|
||||
_ = n.Build(nil, idxNode.Content[0], idx)
|
||||
_ = n.Build(context.Background(), nil, idxNode.Content[0], idx)
|
||||
assert.Len(t, n.Default.Value.(map[string]any), 2)
|
||||
}
|
||||
|
||||
@@ -95,7 +96,7 @@ func TestParameter_NoDefaultNoError(t *testing.T) {
|
||||
var n Parameter
|
||||
_ = low.BuildModel(&idxNode, &n)
|
||||
|
||||
err := n.Build(nil, idxNode.Content[0], idx)
|
||||
err := n.Build(context.Background(), nil, idxNode.Content[0], idx)
|
||||
assert.NoError(t, err)
|
||||
}
|
||||
|
||||
@@ -136,7 +137,7 @@ required: true`
|
||||
|
||||
var n Parameter
|
||||
_ = low.BuildModel(idxNode.Content[0], &n)
|
||||
_ = n.Build(nil, idxNode.Content[0], idx)
|
||||
_ = n.Build(context.Background(), nil, idxNode.Content[0], idx)
|
||||
|
||||
yml2 := `items:
|
||||
type: int
|
||||
@@ -174,7 +175,7 @@ allowEmptyValue: true
|
||||
|
||||
var n2 Parameter
|
||||
_ = low.BuildModel(idxNode2.Content[0], &n2)
|
||||
_ = n2.Build(nil, idxNode2.Content[0], idx2)
|
||||
_ = n2.Build(context.Background(), nil, idxNode2.Content[0], idx2)
|
||||
|
||||
// hash
|
||||
assert.Equal(t, n.Hash(), n2.Hash())
|
||||
|
||||
Reference in New Issue
Block a user