mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2025-06-21 08:30:50 +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
|
@ -205,13 +205,13 @@ func TestRenameUser(t *testing.T) {
|
|||
unittest.AssertExistsIf(t, true, &user_model.Redirect{LowerName: "user_rename"})
|
||||
|
||||
// The granularity of created_unix is a second.
|
||||
time.Sleep(time.Second)
|
||||
test.SleepTillNextSecond()
|
||||
require.NoError(t, RenameUser(db.DefaultContext, user, "redirect-2"))
|
||||
unittest.AssertExistsIf(t, false, &user_model.Redirect{LowerName: "user_rename"})
|
||||
unittest.AssertExistsIf(t, true, &user_model.Redirect{LowerName: "redirect-1"})
|
||||
|
||||
setting.Service.MaxUserRedirects = 2
|
||||
time.Sleep(time.Second)
|
||||
test.SleepTillNextSecond()
|
||||
require.NoError(t, RenameUser(db.DefaultContext, user, "redirect-3"))
|
||||
unittest.AssertExistsIf(t, true, &user_model.Redirect{LowerName: "redirect-1"})
|
||||
unittest.AssertExistsIf(t, true, &user_model.Redirect{LowerName: "redirect-2"})
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue