Skip to content

Commit

Permalink
Merge pull request #38 from danielgtaylor/responses-unit-tests
Browse files Browse the repository at this point in the history
chore: adding unit test for responses.ServeContent for codecov
  • Loading branch information
deo986 authored Apr 7, 2022
2 parents 010fc90 + e3e12ba commit 9d74b11
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions responses/responses_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,3 +96,23 @@ func TestResponses(t *testing.T) {
String(http.StatusOK)
assert.Equal(t, 200, status)
}

func contains(r []huma.Response, e huma.Response) bool {
for _, i := range r {
if i.GetStatus() == e.GetStatus() {
return true
}
}
return false
}

func TestWriteContentResponses(t *testing.T) {
r := ServeContent()

assert.Equal(t, 5, len(r))
assert.True(t, contains(r, OK()))
assert.True(t, contains(r, PartialContent()))
assert.True(t, contains(r, NotModified()))
assert.True(t, contains(r, PreconditionFailed()))
assert.True(t, contains(r, InternalServerError()))
}

0 comments on commit 9d74b11

Please sign in to comment.