Skip to content

Commit

Permalink
Added test for panic when path is missing
Browse files Browse the repository at this point in the history
  • Loading branch information
k1LoW authored and daveshanley committed Mar 26, 2024
1 parent f866c7b commit 8c0c19f
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions paths/paths_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -634,3 +634,28 @@ paths:
assert.Equal(t, "two", pathItem.Post.OperationId)

}

func TestNewValidator_FindPathMissingWithBaseURLInServer(t *testing.T) {

spec := `openapi: 3.1.0
servers:
- url: 'https://things.com/'
paths:
/dishy:
get:
operationId: one
`

doc, err := libopenapi.NewDocument([]byte(spec))
if err != nil {
t.Fatal(err)
}
m, _ := doc.BuildV3Model()

request, _ := http.NewRequest(http.MethodGet, "https://things.com/not_here", nil)

_, errs, _ := FindPath(request, &m.Model)
assert.Len(t, errs, 1)
assert.Equal(t, "GET Path '/not_here' not found", errs[0].Message)

}

0 comments on commit 8c0c19f

Please sign in to comment.