mirror of
https://github.com/go-gitea/gitea
synced 2025-07-22 18:28:37 +00:00
more context for models (#19511)
make more usage of context, to have more db transaction in one session (make diff of #9307 smaller)
This commit is contained in:
@@ -7,6 +7,7 @@ package models
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"code.gitea.io/gitea/models/db"
|
||||
repo_model "code.gitea.io/gitea/models/repo"
|
||||
"code.gitea.io/gitea/models/unittest"
|
||||
|
||||
@@ -99,11 +100,14 @@ func TestRenameBranch(t *testing.T) {
|
||||
repo1 := unittest.AssertExistsAndLoadBean(t, &repo_model.Repository{ID: 1}).(*repo_model.Repository)
|
||||
_isDefault := false
|
||||
|
||||
err := UpdateProtectBranch(repo1, &ProtectedBranch{
|
||||
ctx, committer, err := db.TxContext()
|
||||
defer committer.Close()
|
||||
assert.NoError(t, err)
|
||||
assert.NoError(t, UpdateProtectBranch(ctx, repo1, &ProtectedBranch{
|
||||
RepoID: repo1.ID,
|
||||
BranchName: "master",
|
||||
}, WhitelistOptions{})
|
||||
assert.NoError(t, err)
|
||||
}, WhitelistOptions{}))
|
||||
assert.NoError(t, committer.Commit())
|
||||
|
||||
assert.NoError(t, RenameBranch(repo1, "master", "main", func(isDefault bool) error {
|
||||
_isDefault = isDefault
|
||||
|
Reference in New Issue
Block a user