mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2025-06-09 08:07:40 +00:00
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:
parent
112ba66637
commit
fa2a135f68
44 changed files with 155 additions and 264 deletions
|
@ -12,6 +12,7 @@ import (
|
|||
|
||||
"forgejo.org/modules/json"
|
||||
"forgejo.org/modules/setting"
|
||||
"forgejo.org/modules/test"
|
||||
"forgejo.org/routers"
|
||||
"forgejo.org/tests"
|
||||
|
||||
|
@ -53,16 +54,11 @@ func sessionFileExist(t *testing.T, tmpDir, sessionID string) bool {
|
|||
|
||||
func TestSessionFileCreation(t *testing.T) {
|
||||
defer tests.PrepareTestEnv(t)()
|
||||
|
||||
oldSessionConfig := setting.SessionConfig.ProviderConfig
|
||||
defer func() {
|
||||
setting.SessionConfig.ProviderConfig = oldSessionConfig
|
||||
testWebRoutes = routers.NormalRoutes()
|
||||
}()
|
||||
defer test.MockProtect(&setting.SessionConfig.ProviderConfig)()
|
||||
defer test.MockProtect(&testWebRoutes)()
|
||||
|
||||
var config session.Options
|
||||
|
||||
err := json.Unmarshal([]byte(oldSessionConfig), &config)
|
||||
err := json.Unmarshal([]byte(setting.SessionConfig.ProviderConfig), &config)
|
||||
require.NoError(t, err)
|
||||
|
||||
config.Provider = "file"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue