Fix tests

This commit is contained in:
Ben Visness 2022-09-10 10:39:19 -05:00
parent 6cec54f8cc
commit 42574ca847
3 changed files with 30 additions and 29 deletions

View File

@ -75,7 +75,7 @@ func TestLogoutAction(t *testing.T) {
}
func TestRegister(t *testing.T) {
AssertRegexMatch(t, BuildRegister(), RegexRegister, nil)
AssertRegexMatch(t, BuildRegister(""), RegexRegister, nil)
}
func TestRegistrationSuccess(t *testing.T) {
@ -83,7 +83,7 @@ func TestRegistrationSuccess(t *testing.T) {
}
func TestEmailConfirmation(t *testing.T) {
AssertRegexMatch(t, BuildEmailConfirmation("mruser", "test_token"), RegexEmailConfirmation, map[string]string{"username": "mruser", "token": "test_token"})
AssertRegexMatch(t, BuildEmailConfirmation("mruser", "test_token", ""), RegexEmailConfirmation, map[string]string{"username": "mruser", "token": "test_token"})
}
func TestPasswordReset(t *testing.T) {
@ -370,6 +370,26 @@ func TestJamIndex(t *testing.T) {
AssertSubdomain(t, BuildJamIndex(), "")
}
func TestJamIndex2021(t *testing.T) {
AssertRegexMatch(t, BuildJamIndex2021(), RegexJamIndex2021, nil)
AssertSubdomain(t, BuildJamIndex2021(), "")
}
func TestJamIndex2022(t *testing.T) {
AssertRegexMatch(t, BuildJamIndex2022(), RegexJamIndex2022, nil)
AssertSubdomain(t, BuildJamIndex2022(), "")
}
func TestJamFeed2022(t *testing.T) {
AssertRegexMatch(t, BuildJamFeed2022(), RegexJamFeed2022, nil)
AssertSubdomain(t, BuildJamFeed2022(), "")
}
func TestProjectNewJam(t *testing.T) {
AssertRegexMatch(t, BuildProjectNewJam(), RegexProjectNew, nil)
AssertSubdomain(t, BuildProjectNewJam(), "")
}
func TestDiscordOAuthCallback(t *testing.T) {
AssertRegexMatch(t, BuildDiscordOAuthCallback(), RegexDiscordOAuthCallback, nil)
}

View File

@ -61,27 +61,6 @@ func main() {
assert.Contains(t, html, "Hello, world!")
})
})
t.Run("education", func(t *testing.T) {
t.Run("[glossary]", func(t *testing.T) {
html := ParseMarkdown("[glossary=foo]Foo Protocol[/glossary]", EducationRealMarkdown)
t.Log(html)
assert.Equal(t, 1, strings.Count(html, "<a"))
assert.Contains(t, html, `class="glossary-term"`)
assert.Contains(t, html, `data-term="foo"`)
})
t.Run("[note]", func(t *testing.T) {
html := ParseMarkdown("[note]This should only appear to editors![/note]", EducationRealMarkdown)
t.Log(html)
assert.Equal(t, 1, strings.Count(html, "<div"))
assert.Contains(t, html, `class="education-note"`)
})
t.Run("[resource]", func(t *testing.T) {
html := ParseMarkdown(`[resource name="cool name" url="blep"]Excellent description.[/resource]`, EducationRealMarkdown)
t.Log(html)
t.Fail()
})
})
}
func TestSharlock(t *testing.T) {

View File

@ -28,12 +28,14 @@ func TestLogContextErrors(t *testing.T) {
router := &Router{}
routes := RouteBuilder{
Router: router,
Middleware: func(h Handler) Handler {
return func(c *RequestContext) (res ResponseData) {
c.Logger = &logger
defer logContextErrorsMiddleware(c, &res)
return h(c)
}
Middlewares: []Middleware{
func(h Handler) Handler {
return func(c *RequestContext) (res ResponseData) {
c.Logger = &logger
defer logContextErrorsMiddleware(h)
return h(c)
}
},
},
}