use errHandler in admin tests
This commit is contained in:
parent
cae80e385e
commit
3651432b42
|
@ -159,8 +159,7 @@ func TestInvitesCreate(t *testing.T) {
|
|||
_, userID := ts.InvitesDB.CreateArgsForCall(totalCreateCallCount - 1)
|
||||
a.EqualValues(ts.User.ID, userID)
|
||||
} else {
|
||||
// TODO: status should be http.StatusForbidden? see invites.go:79
|
||||
a.Equal(http.StatusInternalServerError, rec.Code)
|
||||
a.Equal(http.StatusForbidden, rec.Code)
|
||||
r.Equal(totalCreateCallCount, ts.InvitesDB.CreateCallCount())
|
||||
}
|
||||
return rec
|
||||
|
|
|
@ -89,7 +89,7 @@ func TestNoticeAddLanguageOnlyAllowsPost(t *testing.T) {
|
|||
// verify that a GET request is no bueno
|
||||
u := ts.URLTo(router.AdminNoticeAddTranslation, "name", roomdb.NoticeNews.String())
|
||||
_, resp := ts.Client.GetHTML(u)
|
||||
a.Equal(http.StatusMethodNotAllowed, resp.Code, "GET should not be allowed for this route")
|
||||
a.Equal(http.StatusBadRequest, resp.Code, "GET should not be allowed for this route")
|
||||
|
||||
// next up, we verify that a correct POST request actually works:
|
||||
id := []string{"1"}
|
||||
|
|
|
@ -130,10 +130,10 @@ func newSession(t *testing.T) *testSession {
|
|||
os.MkdirAll(sessionsPath, 0700)
|
||||
fsStore := sessions.NewFilesystemStore(sessionsPath, authKey, encKey)
|
||||
|
||||
// setup rendering
|
||||
flashHelper := weberrs.NewFlashHelper(fsStore, locHelper)
|
||||
|
||||
// setup rendering
|
||||
|
||||
// template funcs
|
||||
// TODO: make testing utils and move these there
|
||||
testFuncs := web.TemplateFuncs(router, ts.netInfo)
|
||||
testFuncs["current_page_is"] = func(routeName string) bool { return true }
|
||||
|
@ -152,11 +152,13 @@ func newSession(t *testing.T) *testSession {
|
|||
testFuncs["list_languages"] = func(*url.URL, string) string { return "" }
|
||||
testFuncs["relative_time"] = func(when time.Time) string { return humanize.Time(when) }
|
||||
|
||||
eh := weberrs.NewErrorHandler(locHelper, flashHelper)
|
||||
|
||||
renderOpts := []render.Option{
|
||||
render.SetLogger(log),
|
||||
render.BaseTemplates("base.tmpl", "menu.tmpl", "flashes.tmpl"),
|
||||
render.AddTemplates(append(HTMLTemplates, "error.tmpl")...),
|
||||
render.ErrorTemplate("error.tmpl"),
|
||||
render.SetErrorHandler(eh.Handle),
|
||||
render.FuncMap(testFuncs),
|
||||
}
|
||||
renderOpts = append(renderOpts, locHelper.GetRenderFuncs()...)
|
||||
|
@ -166,6 +168,8 @@ func newSession(t *testing.T) *testSession {
|
|||
t.Fatal(errors.Wrap(err, "setup: render init failed"))
|
||||
}
|
||||
|
||||
eh.SetRenderer(r)
|
||||
|
||||
handler := Handler(
|
||||
ts.netInfo,
|
||||
r,
|
||||
|
|
Loading…
Reference in New Issue