aboutsummaryrefslogtreecommitdiffstats
path: root/models/branches_test.go
diff options
context:
space:
mode:
author6543 <6543@obermui.de>2022-04-28 13:48:48 +0200
committerGitHub <noreply@github.com>2022-04-28 13:48:48 +0200
commit06e4687cecaed41500b653e5b8685f48b8b18310 (patch)
treea98dd6d0139ba5d89c7e08d3c52930d66a77119b /models/branches_test.go
parent332b2ecd214a79b49f3798f4f27fe02b23a17bf8 (diff)
downloadgitea-06e4687cecaed41500b653e5b8685f48b8b18310.tar.gz
gitea-06e4687cecaed41500b653e5b8685f48b8b18310.zip
more context for models (#19511)
make more usage of context, to have more db transaction in one session (make diff of #9307 smaller)
Diffstat (limited to 'models/branches_test.go')
-rw-r--r--models/branches_test.go10
1 files changed, 7 insertions, 3 deletions
diff --git a/models/branches_test.go b/models/branches_test.go
index e1a71853f2..0a0f125cc6 100644
--- a/models/branches_test.go
+++ b/models/branches_test.go
@@ -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