From e3e12ba5e14db8b7b7c56c3d486fa41d11bf0a3e Mon Sep 17 00:00:00 2001 From: Andrew Orban Date: Thu, 7 Apr 2022 03:22:14 +0000 Subject: [PATCH] chore: adding unit test for responses.ServeContent for codecov --- responses/responses_test.go | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/responses/responses_test.go b/responses/responses_test.go index c390e72d..3ce81bdd 100644 --- a/responses/responses_test.go +++ b/responses/responses_test.go @@ -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())) +}