Files
libopenapi/index/rolodex_ref_extractor_test.go
quobix 28047d08d2 First sweep at cleaning up dead code
first round of a number I am sure, lots to clean.

Signed-off-by: quobix <dave@quobix.com>
2023-10-21 18:26:21 -04:00

36 lines
1.1 KiB
Go

// Copyright 2023 Princess B33f Heavy Industries / Dave Shanley
// SPDX-License-Identifier: MIT
package index
import (
"github.com/stretchr/testify/assert"
"testing"
)
func TestExtractedRef_GetFile(t *testing.T) {
a := &ExtractedRef{Location: "#/components/schemas/One", Type: Local}
assert.Equal(t, "#/components/schemas/One", a.GetFile())
a = &ExtractedRef{Location: "pizza.yaml#/components/schemas/One", Type: File}
assert.Equal(t, "pizza.yaml", a.GetFile())
a = &ExtractedRef{Location: "https://api.pb33f.io/openapi.yaml#/components/schemas/One", Type: File}
assert.Equal(t, "https://api.pb33f.io/openapi.yaml", a.GetFile())
}
func TestExtractedRef_GetReference(t *testing.T) {
a := &ExtractedRef{Location: "#/components/schemas/One", Type: Local}
assert.Equal(t, "#/components/schemas/One", a.GetReference())
a = &ExtractedRef{Location: "pizza.yaml#/components/schemas/One", Type: File}
assert.Equal(t, "#/components/schemas/One", a.GetReference())
a = &ExtractedRef{Location: "https://api.pb33f.io/openapi.yaml#/components/schemas/One", Type: File}
assert.Equal(t, "#/components/schemas/One", a.GetReference())
}