chore: add more test coverage

This commit is contained in:
Tristan Cartledge
2023-12-14 14:46:20 +00:00
parent eec2dfa29d
commit 0119853344
3 changed files with 57 additions and 7 deletions

View File

@@ -5,6 +5,7 @@ import (
"testing"
"github.com/pb33f/libopenapi/orderedmap"
"github.com/pb33f/libopenapi/utils"
"github.com/stretchr/testify/assert"
"gopkg.in/yaml.v3"
)
@@ -407,3 +408,17 @@ func TestBuildModelAsync(t *testing.T) {
wg.Wait()
assert.Equal(t, 3, orderedmap.Len(ins.Thing.Value))
}
func TestSetField_NilValueNode(t *testing.T) {
assert.NotPanics(t, func() {
SetField(nil, nil, nil)
})
}
func TestBuildModelAsync_HandlesError(t *testing.T) {
errs := []error{}
wg := sync.WaitGroup{}
wg.Add(1)
BuildModelAsync(utils.CreateStringNode("cake"), "cake", &wg, &errs)
assert.NotEmpty(t, errs)
}