mirror of
https://github.com/LukeHagar/libopenapi.git
synced 2025-12-10 04:20:24 +00:00
Fix tests.
This commit is contained in:
@@ -5,25 +5,27 @@ package renderer
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
"strings"
|
||||||
|
"testing"
|
||||||
|
|
||||||
highbase "github.com/pb33f/libopenapi/datamodel/high/base"
|
highbase "github.com/pb33f/libopenapi/datamodel/high/base"
|
||||||
"github.com/pb33f/libopenapi/datamodel/low"
|
"github.com/pb33f/libopenapi/datamodel/low"
|
||||||
lowbase "github.com/pb33f/libopenapi/datamodel/low/base"
|
lowbase "github.com/pb33f/libopenapi/datamodel/low/base"
|
||||||
|
"github.com/pb33f/libopenapi/orderedmap"
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
"gopkg.in/yaml.v3"
|
"gopkg.in/yaml.v3"
|
||||||
"strings"
|
|
||||||
"testing"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type fakeMockable struct {
|
type fakeMockable struct {
|
||||||
Schema *highbase.SchemaProxy
|
Schema *highbase.SchemaProxy
|
||||||
Example any
|
Example any
|
||||||
Examples map[string]*highbase.Example
|
Examples orderedmap.Map[string, *highbase.Example]
|
||||||
}
|
}
|
||||||
|
|
||||||
type fakeMockableButWithASchemaNotAProxy struct {
|
type fakeMockableButWithASchemaNotAProxy struct {
|
||||||
Schema *highbase.Schema
|
Schema *highbase.Schema
|
||||||
Example any
|
Example any
|
||||||
Examples map[string]*highbase.Example
|
Examples orderedmap.Map[string, *highbase.Example]
|
||||||
}
|
}
|
||||||
|
|
||||||
var simpleFakeMockSchema = `type: string
|
var simpleFakeMockSchema = `type: string
|
||||||
@@ -48,12 +50,12 @@ func createFakeMock(mock string, values map[string]any, example any) *fakeMockab
|
|||||||
Value: &lowProxy,
|
Value: &lowProxy,
|
||||||
}
|
}
|
||||||
highSchema := highbase.NewSchemaProxy(&lowRef)
|
highSchema := highbase.NewSchemaProxy(&lowRef)
|
||||||
examples := make(map[string]*highbase.Example)
|
examples := orderedmap.New[string, *highbase.Example]()
|
||||||
|
|
||||||
for k, v := range values {
|
for k, v := range values {
|
||||||
examples[k] = &highbase.Example{
|
examples.Set(k, &highbase.Example{
|
||||||
Value: v,
|
Value: v,
|
||||||
}
|
})
|
||||||
}
|
}
|
||||||
return &fakeMockable{
|
return &fakeMockable{
|
||||||
Schema: highSchema,
|
Schema: highSchema,
|
||||||
@@ -71,12 +73,12 @@ func createFakeMockWithoutProxy(mock string, values map[string]any, example any)
|
|||||||
Value: &lowProxy,
|
Value: &lowProxy,
|
||||||
}
|
}
|
||||||
highSchema := highbase.NewSchemaProxy(&lowRef)
|
highSchema := highbase.NewSchemaProxy(&lowRef)
|
||||||
examples := make(map[string]*highbase.Example)
|
examples := orderedmap.New[string, *highbase.Example]()
|
||||||
|
|
||||||
for k, v := range values {
|
for k, v := range values {
|
||||||
examples[k] = &highbase.Example{
|
examples.Set(k, &highbase.Example{
|
||||||
Value: v,
|
Value: v,
|
||||||
}
|
})
|
||||||
}
|
}
|
||||||
return &fakeMockableButWithASchemaNotAProxy{
|
return &fakeMockableButWithASchemaNotAProxy{
|
||||||
Schema: highSchema.Schema(),
|
Schema: highSchema.Schema(),
|
||||||
|
|||||||
Reference in New Issue
Block a user