You've already forked Go-Template
Future self, please forgive me and don't hit me with the baseball bat again!
This commit is contained in:
27
http_handlers/errors/notfound_test.go
Normal file
27
http_handlers/errors/notfound_test.go
Normal file
@@ -0,0 +1,27 @@
|
||||
package errors
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"testing"
|
||||
|
||||
"github.com/labstack/echo/v4"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestNewNotFoundError(t *testing.T) {
|
||||
e := echo.New()
|
||||
req := httptest.NewRequest(http.MethodGet, "/notfound", nil)
|
||||
rec := httptest.NewRecorder()
|
||||
c := e.NewContext(req, rec)
|
||||
|
||||
err := NewNotFoundError(c)
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, http.StatusNotFound, rec.Code)
|
||||
|
||||
var resp map[string]string
|
||||
e2 := json.Unmarshal(rec.Body.Bytes(), &resp)
|
||||
assert.NoError(t, e2)
|
||||
assert.Equal(t, "Not Found", resp["error"])
|
||||
}
|
||||
Reference in New Issue
Block a user