mirror of
https://github.com/go-gitea/gitea.git
synced 2026-10-24 05:39:46 +02:00
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:
1 parent
ef55965d98
commit
98c613d943
20 files changed
+124
-66
No files matched your search
@@ -79,8 +79,9 @@ func TestIndexer(t *testing.T, indexer internal.Indexer) {
|
||||
}
|
||||
|
||||
// test counting
|
||||
c.SearchOptions.Paginator = &db.ListOptions{PageSize: 0}
|
||||
countResult, err := indexer.Search(t.Context(), c.SearchOptions)
|
||||
countOptions := c.SearchOptions.Copy()
|
||||
countOptions.Paginator = &db.ListOptions{PageSize: 0}
|
||||
countResult, err := indexer.Search(t.Context(), countOptions)
|
||||
require.NoError(t, err)
|
||||
assert.Empty(t, countResult.Hits)
|
||||
assert.Equal(t, result.Total, countResult.Total)
|
||||
|
||||
Reference in new issue
Block a user