bumped coverage

This commit is contained in:
quobix
2024-04-18 18:23:16 -04:00
parent 099d4b324a
commit a20a09710b
3 changed files with 13 additions and 1 deletions

View File

@@ -76,7 +76,7 @@ func CreateSchemaProxyRef(ref string) *SchemaProxy {
// If there is a problem building the Schema, then this method will return nil. Use GetBuildError to gain access // If there is a problem building the Schema, then this method will return nil. Use GetBuildError to gain access
// to that building error. // to that building error.
func (sp *SchemaProxy) Schema() *Schema { func (sp *SchemaProxy) Schema() *Schema {
if sp == nil { if sp == nil || sp.lock == nil {
return nil return nil
} }
sp.lock.Lock() sp.lock.Lock()

View File

@@ -60,6 +60,11 @@ func TestSchemaProxy_MarshalYAML(t *testing.T) {
assert.Equal(t, "$ref: '#/components/schemas/nice'", strings.TrimSpace(string(rend))) assert.Equal(t, "$ref: '#/components/schemas/nice'", strings.TrimSpace(string(rend)))
} }
func TestCreateSchemaProxy_Fail(t *testing.T) {
proxy := &SchemaProxy{}
assert.Nil(t, proxy.Schema())
}
func TestCreateSchemaProxy(t *testing.T) { func TestCreateSchemaProxy(t *testing.T) {
sp := CreateSchemaProxy(&Schema{Description: "iAmASchema"}) sp := CreateSchemaProxy(&Schema{Description: "iAmASchema"})
assert.Equal(t, "iAmASchema", sp.rendered.Description) assert.Equal(t, "iAmASchema", sp.rendered.Description)

View File

@@ -59,6 +59,13 @@ definitions:
assert.Nil(t, v2Doc) assert.Nil(t, v2Doc)
} }
func TestLoadDocument_WrongDoc(t *testing.T) {
yml := `IAmNotAnOpenAPI: 3.1.0`
doc, err := NewDocument([]byte(yml))
assert.Error(t, err)
assert.Nil(t, doc)
}
func TestLoadDocument_Simple_V3_Error(t *testing.T) { func TestLoadDocument_Simple_V3_Error(t *testing.T) {
yml := `openapi: 3.0.1` yml := `openapi: 3.0.1`
doc, err := NewDocument([]byte(yml)) doc, err := NewDocument([]byte(yml))