Skip to content

Commit

Permalink
Update http error code on FizzBuzz endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
codeinuit committed Aug 8, 2023
1 parent fc0209a commit 283f90d
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion cmd/api/handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ func (h handlers) fizzbuzz(c *gin.Context) {

fb, err := fizzbuzz.FizzBuzz(v.Int1, v.Int2, v.Int3, v.String1, v.String2)
if err != nil {
c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()})
c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
return
}

Expand Down
2 changes: 1 addition & 1 deletion cmd/api/handlers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,5 +101,5 @@ func TestGetFizzBuzzWrongParameter(t *testing.T) {
req, _ := http.NewRequest("GET", "/fizzbuzz", &b)
fb.engine.ServeHTTP(w, req)

assert.Equal(t, 500, w.Code)
assert.Equal(t, 400, w.Code)
}

0 comments on commit 283f90d

Please sign in to comment.