diff --git a/index/search_index_test.go b/index/search_index_test.go index 3ebed4b..62dd2a8 100644 --- a/index/search_index_test.go +++ b/index/search_index_test.go @@ -6,7 +6,6 @@ package index import ( "github.com/stretchr/testify/assert" "gopkg.in/yaml.v3" - "net/url" "os" "testing" ) @@ -22,32 +21,3 @@ func TestSpecIndex_SearchIndexForReference(t *testing.T) { ref := idx.SearchIndexForReference("#/components/schemas/Pet") assert.NotNil(t, ref) } - -func TestSpecIndex_SearchIndexForReference_ExternalSpecs(t *testing.T) { - - // load up an index with lots of references - petstore, _ := os.ReadFile("../test_specs/digitalocean.yaml") - var rootNode yaml.Node - _ = yaml.Unmarshal(petstore, &rootNode) - - c := CreateOpenAPIIndexConfig() - c.BaseURL, _ = url.Parse("https://raw.githubusercontent.com/digitalocean/openapi/main/specification") - idx := NewSpecIndexWithConfig(&rootNode, c) - - ref := idx.SearchIndexForReference("resources/apps/apps_list_instanceSizes.yml") - assert.NotNil(t, ref) - assert.Equal(t, "operationId", ref[0].Node.Content[0].Value) - - ref = idx.SearchIndexForReference("examples/ruby/domains_create.yml") - assert.NotNil(t, ref) - assert.Equal(t, "lang", ref[0].Node.Content[0].Value) - - ref = idx.SearchIndexForReference("../../shared/responses/server_error.yml") - assert.NotNil(t, ref) - assert.Equal(t, "description", ref[0].Node.Content[0].Value) - - ref = idx.SearchIndexForReference("../models/options.yml") - assert.NotNil(t, ref) - assert.Equal(t, "kubernetes_options", ref[0].Node.Content[0].Value) - -} diff --git a/index/spec_index_test.go b/index/spec_index_test.go index fad95e4..2cc0780 100644 --- a/index/spec_index_test.go +++ b/index/spec_index_test.go @@ -123,6 +123,22 @@ func TestSpecIndex_DigitalOcean_FullCheckoutLocalResolve(t *testing.T) { assert.Len(t, index.GetAllExternalIndexes(), 291) assert.NotNil(t, index) + + ref := index.SearchIndexForReference("resources/apps/apps_list_instanceSizes.yml") + assert.NotNil(t, ref) + assert.Equal(t, "operationId", ref[0].Node.Content[0].Value) + + ref = index.SearchIndexForReference("examples/ruby/domains_create.yml") + assert.NotNil(t, ref) + assert.Equal(t, "lang", ref[0].Node.Content[0].Value) + + ref = index.SearchIndexForReference("../../shared/responses/server_error.yml") + assert.NotNil(t, ref) + assert.Equal(t, "description", ref[0].Node.Content[0].Value) + + ref = index.SearchIndexForReference("../models/options.yml") + assert.NotNil(t, ref) + } func TestSpecIndex_DigitalOcean_LookupsNotAllowed(t *testing.T) {