Files
libopenapi/index/search_index_test.go
quobix b37b9a2fb9 more coverage bumps to rolodex
Signed-off-by: quobix <dave@quobix.com>
2023-10-31 14:10:48 -04:00

37 lines
972 B
Go

// Copyright 2023 Princess B33f Heavy Industries / Dave Shanley
// SPDX-License-Identifier: MIT
package index
import (
"context"
"github.com/stretchr/testify/assert"
"gopkg.in/yaml.v3"
"os"
"testing"
)
func TestSpecIndex_SearchIndexForReference(t *testing.T) {
petstore, _ := os.ReadFile("../test_specs/petstorev3.json")
var rootNode yaml.Node
_ = yaml.Unmarshal(petstore, &rootNode)
c := CreateOpenAPIIndexConfig()
idx := NewSpecIndexWithConfig(&rootNode, c)
ref, _ := idx.SearchIndexForReference("#/components/schemas/Pet")
assert.NotNil(t, ref)
}
func TestSpecIndex_SearchIndexForReferenceWithContext(t *testing.T) {
petstore, _ := os.ReadFile("../test_specs/petstorev3.json")
var rootNode yaml.Node
_ = yaml.Unmarshal(petstore, &rootNode)
c := CreateOpenAPIIndexConfig()
idx := NewSpecIndexWithConfig(&rootNode, c)
ref, _, _ := idx.SearchIndexForReferenceWithContext(context.Background(), "#/components/schemas/Pet")
assert.NotNil(t, ref)
}