Skip to content

Commit

Permalink
Add test for BindHeader with invalid data type
Browse files Browse the repository at this point in the history
  • Loading branch information
noseglid committed May 13, 2021
1 parent e30a353 commit 11d6bf8
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions bind_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,22 @@ func TestBindHeaderParam(t *testing.T) {
}
}

func TestBindHeaderParamBadType(t *testing.T) {
e := New()
req := httptest.NewRequest(http.MethodGet, "/", nil)
req.Header.Set("Id", "salamander")
rec := httptest.NewRecorder()
c := e.NewContext(req, rec)
u := new(user)
err := (&DefaultBinder{}).BindHeaders(c, u)
assert.Error(t, err)

httpErr, ok := err.(*HTTPError)
if assert.True(t, ok) {
assert.Equal(t, http.StatusBadRequest, httpErr.Code)
}
}

func TestBindUnmarshalParam(t *testing.T) {
e := New()
req := httptest.NewRequest(http.MethodGet, "/?ts=2016-12-06T19:09:05Z&sa=one,two,three&ta=2016-12-06T19:09:05Z&ta=2016-12-06T19:09:05Z&ST=baz", nil)
Expand Down

0 comments on commit 11d6bf8

Please sign in to comment.