Bumped coverage on utility methods

fallen slightly, bumpy bump.
This commit is contained in:
Dave Shanley
2023-03-06 10:51:59 -05:00
parent 581423016f
commit 1ac5fbe9fc
2 changed files with 23 additions and 1 deletions

View File

@@ -405,7 +405,7 @@ func GenerateCleanSpecConfigBaseURL(baseURL *url.URL, dir string, includeFile bo
if !includeFile { if !includeFile {
dirSegs = dirSegs[:len(dirSegs)-1] dirSegs = dirSegs[:len(dirSegs)-1]
} }
// relative paths are a pain in the ass, damn you digital ocean, use a single spec, and break them // relative paths are a pain in the ass, damn you digital ocean, use a single spec, and break them
// down into services, please don't blast apart specs into a billion shards. // down into services, please don't blast apart specs into a billion shards.
if strings.Contains(dir, "../") { if strings.Contains(dir, "../") {

View File

@@ -26,6 +26,28 @@ func TestGenerateCleanSpecConfigBaseURL_RelativeDeep(t *testing.T) {
GenerateCleanSpecConfigBaseURL(u, path, true)) GenerateCleanSpecConfigBaseURL(u, path, true))
} }
func TestGenerateCleanSpecConfigBaseURL_NoBaseURL(t *testing.T) {
u, _ := url.Parse("/things/stuff/jazz/cakes/winter/oil")
path := "../../../../foo/bar/baz/crap.yaml#thang"
assert.Equal(t, "/things/stuff/foo/bar/baz",
GenerateCleanSpecConfigBaseURL(u, path, false))
assert.Equal(t, "/things/stuff/foo/bar/baz/crap.yaml#thang",
GenerateCleanSpecConfigBaseURL(u, path, true))
}
func TestGenerateCleanSpecConfigBaseURL_HttpStrip(t *testing.T) {
u, _ := url.Parse(".")
path := "http://thing.com/crap.yaml#thang"
assert.Equal(t, "http://thing.com",
GenerateCleanSpecConfigBaseURL(u, path, false))
assert.Equal(t, "",
GenerateCleanSpecConfigBaseURL(u, "crap.yaml#thing", true))
}
func TestSpecIndex_extractDefinitionRequiredRefProperties(t *testing.T) { func TestSpecIndex_extractDefinitionRequiredRefProperties(t *testing.T) {
c := CreateOpenAPIIndexConfig() c := CreateOpenAPIIndexConfig()
idx := NewSpecIndexWithConfig(nil, c) idx := NewSpecIndexWithConfig(nil, c)