From 2b830ee90486e64909039f7970c641c30e711719 Mon Sep 17 00:00:00 2001 From: Lunny Xiao Date: Thu, 2 Jan 2025 22:26:40 -0800 Subject: [PATCH] Fix tests --- models/fixtures/branch.yml | 21 +++++++++++++++++++++ routers/web/repo/compare.go | 2 ++ tests/integration/api_branch_test.go | 4 ++-- 3 files changed, 25 insertions(+), 2 deletions(-) diff --git a/models/fixtures/branch.yml b/models/fixtures/branch.yml index abd7746184..a4af5400f6 100644 --- a/models/fixtures/branch.yml +++ b/models/fixtures/branch.yml @@ -131,3 +131,24 @@ commit_time: 1489956479 pusher_id: 1 is_deleted: false + +- + id: 20 + repo_id: 1 + name: 'pr-to-update' + commit_id: '62fb502a7172d4453f0322a2cc85bddffa57f07a' + commit_message: 'add WoW File' + commit_time: 1579200695 + pusher_id: 1 + +- + id: 21 + repo_id: 10 + name: 'develop' + commit_id: '65f1bf27bc3bf70f64657658635e66094edbcb4d' + commit_message: 'Initial commit' + commit_time: 1489927679 + pusher_id: 12 + is_deleted: false + deleted_by_id: 0 + deleted_unix: 0 \ No newline at end of file diff --git a/routers/web/repo/compare.go b/routers/web/repo/compare.go index 0b8dc58ea5..9e93ada5eb 100644 --- a/routers/web/repo/compare.go +++ b/routers/web/repo/compare.go @@ -204,6 +204,8 @@ func ParseCompareInfo(ctx *context.Context) *common.CompareInfo { ctx.NotFound("GetRepositoryByOwnerAndName", nil) case errors.Is(err, util.ErrInvalidArgument): ctx.NotFound("ParseComparePathParams", nil) + case git.IsErrNotExist(err): + ctx.NotFound("ParseComparePathParams", nil) default: ctx.ServerError("GetRepositoryByOwnerAndName", err) } diff --git a/tests/integration/api_branch_test.go b/tests/integration/api_branch_test.go index 8a0bd2e4ff..564c25f992 100644 --- a/tests/integration/api_branch_test.go +++ b/tests/integration/api_branch_test.go @@ -270,7 +270,7 @@ func TestAPICreateBranchWithSyncBranches(t *testing.T) { RepoID: 1, }) assert.NoError(t, err) - assert.Len(t, branches, 4) + assert.Len(t, branches, 7) // make a broke repository with no branch on database _, err = db.DeleteByBean(db.DefaultContext, git_model.Branch{RepoID: 1}) @@ -287,7 +287,7 @@ func TestAPICreateBranchWithSyncBranches(t *testing.T) { RepoID: 1, }) assert.NoError(t, err) - assert.Len(t, branches, 5) + assert.Len(t, branches, 8) branches, err = db.Find[git_model.Branch](db.DefaultContext, git_model.FindBranchOptions{ RepoID: 1,