test: fix unit tests failing on repeated runs (#39915)

`go test -count=2` failed in 12 packages because tests leaked state into
later runs.

- Reset SQLite sequences after each fixture load, like PostgreSQL
already does
- Prepare the database in tests that relied on earlier tests doing it
- Restore mutated globals with `test.MockVariableValue`
This commit is contained in:
silverwind authored and GitHub committed 2026-10-22 01:27:02 +00:00
1 parent ef55965d98
commit 98c613d943
20 files changed
+124 -66

No files matched your search

+1 -1
View File
@@ -319,7 +319,7 @@ func TestRenderLabels(t *testing.T) {
}
func TestUserMention(t *testing.T) {
markup.RenderBehaviorForTesting.DisableAdditionalAttributes = true
defer test.MockVariableValue(&markup.RenderBehaviorForTesting.DisableAdditionalAttributes, true)()
rendered := newTestRenderUtils(t).MarkdownToHtml("@no-such-user @mention-user @mention-user")
assert.Equal(t, `<p>@no-such-user <a href="/mention-user" rel="nofollow">@mention-user</a> <a href="/mention-user" rel="nofollow">@mention-user</a></p>`, strings.TrimSpace(string(rendered)))
}