mock injected functions for tests

This commit is contained in:
cblgh 2021-04-15 20:26:09 +02:00
parent ee185e5f43
commit 682283374d
2 changed files with 2 additions and 1 deletions

View File

@ -130,6 +130,8 @@ func newSession(t *testing.T) *testSession {
testFuncs["current_page_is"] = func(routeName string) bool { return true }
testFuncs["is_logged_in"] = func() *roomdb.Member { return &ts.User }
testFuncs["urlToNotice"] = func(name string) string { return "" }
testFuncs["language_count"] = func() int { return 1 }
testFuncs["list_languages"] = func() string { return "" }
testFuncs["relative_time"] = func(when time.Time) string { return humanize.Time(when) }
renderOpts := []render.Option{

View File

@ -185,7 +185,6 @@ func (h Helper) FromRequest(r *http.Request) *Localizer {
session, err := h.cookieStore.Get(r, LanguageCookieName)
if err != nil {
fmt.Printf("cookie error? %w\n", err)
return h.newLocalizer(lang, accept)
}