From 10a9b89d7802287de8ba1d6331d231f4b1ec5ab4 Mon Sep 17 00:00:00 2001 From: Parham Alvani Date: Wed, 23 Oct 2024 09:58:16 +0000 Subject: [PATCH] feat: increase test coverage --- internal/api/api_test.go | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/internal/api/api_test.go b/internal/api/api_test.go index 6d7c065..22f044c 100644 --- a/internal/api/api_test.go +++ b/internal/api/api_test.go @@ -150,7 +150,7 @@ func (suite *APITestSuite) SetupSuite() { suite.app = app } -func (suite *APITestSuite) BadRequest() { +func (suite *APITestSuite) TestBadRequest() { require := suite.Require() body, err := json.Marshal(api.AuthRequest{ @@ -168,10 +168,19 @@ func (suite *APITestSuite) BadRequest() { defer resp.Body.Close() - require.Equal(http.StatusBadRequest, resp.StatusCode) + require.Equal(http.StatusOK, resp.StatusCode) + + data, err := io.ReadAll(resp.Body) + require.NoError(err) + + var authResp api.AuthResponse + + require.NoError(json.Unmarshal(data, &authResp)) + + require.Equal("deny", authResp.Result) } -func (suite *APITestSuite) ValidToken() { +func (suite *APITestSuite) TestValidToken() { require := suite.Require() token, err := getSampleToken(suite.key)