chore: QoL improvements to tests (#7917)

- Use mock helper functions, instead of home-brew solutions.
- Disable cron jobs that are not important to be run during integration tests and might even interfere.
- Avoid sleeping unnecessary, if there's some requirement then sleep or retry until that requirement is met.
- Avoid trying to deliver webhooks that will always result in a failure.

Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/7917
Reviewed-by: Michael Kriese <michael.kriese@gmx.de>
Co-authored-by: Gusted <postmaster@gusted.xyz>
Co-committed-by: Gusted <postmaster@gusted.xyz>
This commit is contained in:
Gusted 2025-05-21 15:45:56 +02:00 committed by Gusted
parent 112ba66637
commit fa2a135f68
44 changed files with 155 additions and 264 deletions

View file

@ -7,7 +7,6 @@ package integration
import (
"net/http"
"testing"
"time"
"forgejo.org/models/db"
"forgejo.org/modules/setting"
@ -97,7 +96,6 @@ func TestDatabaseCollation(t *testing.T) {
defer test.MockVariableValue(&setting.Database.CharsetCollation, "utf8mb4_bin")()
require.NoError(t, db.ConvertDatabaseTable())
time.Sleep(5 * time.Second)
r, err := db.CheckCollations(x)
require.NoError(t, err)
@ -118,7 +116,6 @@ func TestDatabaseCollation(t *testing.T) {
defer test.MockVariableValue(&setting.Database.CharsetCollation, "utf8mb4_general_ci")()
require.NoError(t, db.ConvertDatabaseTable())
time.Sleep(5 * time.Second)
r, err := db.CheckCollations(x)
require.NoError(t, err)
@ -139,7 +136,6 @@ func TestDatabaseCollation(t *testing.T) {
defer test.MockVariableValue(&setting.Database.CharsetCollation, "")()
require.NoError(t, db.ConvertDatabaseTable())
time.Sleep(5 * time.Second)
r, err := db.CheckCollations(x)
require.NoError(t, err)