Skip to content

Commit c8cc3d1

Browse files
committed
Move functions sequence
1 parent d58b2dd commit c8cc3d1

File tree

2 files changed

+26
-26
lines changed

2 files changed

+26
-26
lines changed

models/git/branches_test.go

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -97,31 +97,6 @@ func TestFindRenamedBranch(t *testing.T) {
9797
assert.Equal(t, false, exist)
9898
}
9999

100-
func TestOnlyGetDeletedBranchOnCorrectRepo(t *testing.T) {
101-
assert.NoError(t, unittest.PrepareTestDatabase())
102-
103-
// Get deletedBranch with ID of 1 on repo with ID 2.
104-
// This should return a nil branch as this deleted branch
105-
// is actually on repo with ID 1.
106-
repo2 := unittest.AssertExistsAndLoadBean(t, &repo_model.Repository{ID: 2}).(*repo_model.Repository)
107-
108-
deletedBranch, err := git_model.GetDeletedBranchByID(repo2.ID, 1)
109-
110-
// Expect no error, and the returned branch is nil.
111-
assert.NoError(t, err)
112-
assert.Nil(t, deletedBranch)
113-
114-
// Now get the deletedBranch with ID of 1 on repo with ID 1.
115-
// This should return the deletedBranch.
116-
repo1 := unittest.AssertExistsAndLoadBean(t, &repo_model.Repository{ID: 1}).(*repo_model.Repository)
117-
118-
deletedBranch, err = git_model.GetDeletedBranchByID(repo1.ID, 1)
119-
120-
// Expect no error, and the returned branch to be not nil.
121-
assert.NoError(t, err)
122-
assert.NotNil(t, deletedBranch)
123-
}
124-
125100
func TestRenameBranch(t *testing.T) {
126101
assert.NoError(t, unittest.PrepareTestDatabase())
127102
repo1 := unittest.AssertExistsAndLoadBean(t, &repo_model.Repository{ID: 1}).(*repo_model.Repository)
@@ -161,3 +136,28 @@ func TestRenameBranch(t *testing.T) {
161136
BranchName: "main",
162137
})
163138
}
139+
140+
func TestOnlyGetDeletedBranchOnCorrectRepo(t *testing.T) {
141+
assert.NoError(t, unittest.PrepareTestDatabase())
142+
143+
// Get deletedBranch with ID of 1 on repo with ID 2.
144+
// This should return a nil branch as this deleted branch
145+
// is actually on repo with ID 1.
146+
repo2 := unittest.AssertExistsAndLoadBean(t, &repo_model.Repository{ID: 2}).(*repo_model.Repository)
147+
148+
deletedBranch, err := git_model.GetDeletedBranchByID(repo2.ID, 1)
149+
150+
// Expect no error, and the returned branch is nil.
151+
assert.NoError(t, err)
152+
assert.Nil(t, deletedBranch)
153+
154+
// Now get the deletedBranch with ID of 1 on repo with ID 1.
155+
// This should return the deletedBranch.
156+
repo1 := unittest.AssertExistsAndLoadBean(t, &repo_model.Repository{ID: 1}).(*repo_model.Repository)
157+
158+
deletedBranch, err = git_model.GetDeletedBranchByID(repo1.ID, 1)
159+
160+
// Expect no error, and the returned branch to be not nil.
161+
assert.NoError(t, err)
162+
assert.NotNil(t, deletedBranch)
163+
}

models/git/lfs.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,7 @@ func CopyLFS(ctx context.Context, newRepo, oldRepo *repo_model.Repository) error
317317
for _, v := range lfsObjects {
318318
v.ID = 0
319319
v.RepositoryID = newRepo.ID
320-
if _, err := db.GetEngine(ctx).Insert(v); err != nil {
320+
if err := db.Insert(ctx, v); err != nil {
321321
return err
322322
}
323323
}

0 commit comments

Comments
 (0)