Skip to content

more context for models #19511

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 21 commits into from
Apr 28, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
transaction in tests
  • Loading branch information
6543 committed Apr 27, 2022
commit 61786f8aada3b40b2bf2885ea2a46ebbaf86d99c
9 changes: 6 additions & 3 deletions models/branches_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,11 +100,14 @@ func TestRenameBranch(t *testing.T) {
repo1 := unittest.AssertExistsAndLoadBean(t, &repo_model.Repository{ID: 1}).(*repo_model.Repository)
_isDefault := false

err := UpdateProtectBranch(db.DefaultContext, 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
Expand Down
7 changes: 6 additions & 1 deletion models/issue_label_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,12 @@ func TestDeleteIssueLabel(t *testing.T) {
}
}

assert.NoError(t, DeleteIssueLabel(db.DefaultContext, issue, label, doer))
ctx, committer, err := db.TxContext()
defer committer.Close()
assert.NoError(t, err)
assert.NoError(t, DeleteIssueLabel(ctx, issue, label, doer))
assert.NoError(t, committer.Commit())

unittest.AssertNotExistsBean(t, &IssueLabel{IssueID: issueID, LabelID: labelID})
unittest.AssertExistsAndLoadBean(t, &Comment{
Type: CommentTypeLabel,
Expand Down