Testing example is incorrect


Hi guys,

I’ve been using Echo in my project for some time and started testing some functionality. I’ve been following the guide https://echo.labstack.com/guide/testing and found that provided examples only show successful HTTP 200 cases. When I try to modify test cases to fail. It gives false results.

This is modified version of a function from example. Wrong email is passed as a parameter:

func TestGetUserBad(t *testing.T) {
// Setup
e := echo.New()
req := httptest.NewRequest(http.MethodGet, "/", nil)
rec := httptest.NewRecorder()
c := e.NewContext(req, rec)
c.SetParamValues("[email protected]")
h := &handler{mockDB}
if assert.Error(t, h.getUser(c)) {
assert.Equal(t, http.StatusNotFound, rec.Code)
        	Error:      	Not equal: 
        	            	expected: 404
        	            	actual  : 200

Manual testing confirm handler works just right.

Am I doing something wrong?