tuned coverage

Signed-off-by: quobix <dave@quobix.com>
This commit is contained in:
quobix
2024-02-19 17:31:26 -05:00
parent 56cb1c8694
commit c7378b3adb
2 changed files with 8 additions and 4 deletions

View File

@@ -5,6 +5,8 @@ package base
import (
"context"
"log/slog"
"os"
"testing"
"github.com/pb33f/libopenapi/datamodel/low"
@@ -161,6 +163,9 @@ properties:
func TestSchemaProxy_Build_HashFail(t *testing.T) {
sp := new(SchemaProxy)
logger := slog.New(slog.NewTextHandler(os.Stderr, &slog.HandlerOptions{Level: slog.LevelError}))
idx := index.NewSpecIndexWithConfig(nil, &index.SpecIndexConfig{Logger: logger})
sp.idx = idx
v := sp.Hash()
assert.Equal(t, [32]byte{}, v)
}

View File

@@ -36,9 +36,6 @@ func NewSpecIndexWithConfig(rootNode *yaml.Node, config *SpecIndexConfig) *SpecI
index.rolodex = config.Rolodex
index.uri = config.uri
index.specAbsolutePath = config.SpecAbsolutePath
if rootNode == nil || len(rootNode.Content) <= 0 {
return index
}
if config.Logger != nil {
index.logger = config.Logger
} else {
@@ -46,7 +43,9 @@ func NewSpecIndexWithConfig(rootNode *yaml.Node, config *SpecIndexConfig) *SpecI
Level: slog.LevelError,
}))
}
if rootNode == nil || len(rootNode.Content) <= 0 {
return index
}
index.root = rootNode
return createNewIndex(rootNode, index, config.AvoidBuildIndex)
}