Use test context in tests and new loop system in benchmarks (#33648)
Replace all contexts in tests with go1.24 t.Context() --------- Co-authored-by: Giteabot <teabot@gitea.io> Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
This commit is contained in:
parent
3bbc482879
commit
cc1fdc84ca
108 changed files with 712 additions and 794 deletions
|
@ -4,7 +4,6 @@
|
|||
package integration
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
"os"
|
||||
"strings"
|
||||
|
@ -238,7 +237,7 @@ func TestLDAPUserSync(t *testing.T) {
|
|||
|
||||
defer tests.PrepareTestEnv(t)()
|
||||
te.addAuthSource(t)
|
||||
err := auth.SyncExternalUsers(context.Background(), true)
|
||||
err := auth.SyncExternalUsers(t.Context(), true)
|
||||
assert.NoError(t, err)
|
||||
|
||||
// Check if users exists
|
||||
|
@ -292,7 +291,7 @@ func TestLDAPUserSyncWithEmptyUsernameAttribute(t *testing.T) {
|
|||
MakeRequest(t, req, http.StatusSeeOther)
|
||||
}
|
||||
|
||||
require.NoError(t, auth.SyncExternalUsers(context.Background(), true))
|
||||
require.NoError(t, auth.SyncExternalUsers(t.Context(), true))
|
||||
|
||||
authSource := unittest.AssertExistsAndLoadBean(t, &auth_model.Source{
|
||||
Name: payload["name"],
|
||||
|
@ -328,7 +327,7 @@ func TestLDAPUserSyncWithGroupFilter(t *testing.T) {
|
|||
u := te.otherLDAPUsers[0]
|
||||
testLoginFailed(t, u.UserName, u.Password, translation.NewLocale("en-US").TrString("form.username_password_incorrect"))
|
||||
|
||||
require.NoError(t, auth.SyncExternalUsers(context.Background(), true))
|
||||
require.NoError(t, auth.SyncExternalUsers(t.Context(), true))
|
||||
|
||||
// Assert members of LDAP group "cn=git" are added
|
||||
for _, gitLDAPUser := range te.gitLDAPUsers {
|
||||
|
@ -351,7 +350,7 @@ func TestLDAPUserSyncWithGroupFilter(t *testing.T) {
|
|||
ldapConfig.GroupFilter = "(cn=ship_crew)"
|
||||
require.NoError(t, auth_model.UpdateSource(db.DefaultContext, ldapSource))
|
||||
|
||||
require.NoError(t, auth.SyncExternalUsers(context.Background(), true))
|
||||
require.NoError(t, auth.SyncExternalUsers(t.Context(), true))
|
||||
|
||||
for _, gitLDAPUser := range te.gitLDAPUsers {
|
||||
if gitLDAPUser.UserName == "fry" || gitLDAPUser.UserName == "leela" || gitLDAPUser.UserName == "bender" {
|
||||
|
@ -392,7 +391,7 @@ func TestLDAPUserSSHKeySync(t *testing.T) {
|
|||
defer tests.PrepareTestEnv(t)()
|
||||
te.addAuthSource(t, ldapAuthOptions{attributeSSHPublicKey: "sshPublicKey"})
|
||||
|
||||
require.NoError(t, auth.SyncExternalUsers(context.Background(), true))
|
||||
require.NoError(t, auth.SyncExternalUsers(t.Context(), true))
|
||||
|
||||
// Check if users has SSH keys synced
|
||||
for _, u := range te.gitLDAPUsers {
|
||||
|
@ -432,7 +431,7 @@ func TestLDAPGroupTeamSyncAddMember(t *testing.T) {
|
|||
assert.NoError(t, err)
|
||||
team, err := organization.GetTeam(db.DefaultContext, org.ID, "team11")
|
||||
assert.NoError(t, err)
|
||||
require.NoError(t, auth.SyncExternalUsers(context.Background(), true))
|
||||
require.NoError(t, auth.SyncExternalUsers(t.Context(), true))
|
||||
for _, gitLDAPUser := range te.gitLDAPUsers {
|
||||
user := unittest.AssertExistsAndLoadBean(t, &user_model.User{
|
||||
Name: gitLDAPUser.UserName,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue