diff options
author | wxiaoguang <wxiaoguang@gmail.com> | 2021-11-16 16:53:21 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-11-16 16:53:21 +0800 |
commit | 81926d61db3dac223a75ea49eab893b25a089587 (patch) | |
tree | 627d2f19a008089f3a688e9a94a2cc8d2017afe2 /services | |
parent | 23bd7b1211a80aa3b0dcb60ec4a1c0089ff28dd4 (diff) | |
download | gitea-81926d61db3dac223a75ea49eab893b25a089587.tar.gz gitea-81926d61db3dac223a75ea49eab893b25a089587.zip |
Decouple unit test, remove intermediate `unittestbridge` package (#17662)
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Diffstat (limited to 'services')
-rw-r--r-- | services/attachment/attachment_test.go | 3 | ||||
-rw-r--r-- | services/gitdiff/gitdiff_test.go | 5 | ||||
-rw-r--r-- | services/issue/label_test.go | 17 | ||||
-rw-r--r-- | services/mailer/mail_test.go | 13 | ||||
-rw-r--r-- | services/pull/check_test.go | 7 | ||||
-rw-r--r-- | services/release/release_test.go | 17 | ||||
-rw-r--r-- | services/repository/transfer_test.go | 23 | ||||
-rw-r--r-- | services/webhook/webhook_test.go | 19 | ||||
-rw-r--r-- | services/wiki/wiki_test.go | 19 |
9 files changed, 57 insertions, 66 deletions
diff --git a/services/attachment/attachment_test.go b/services/attachment/attachment_test.go index f44c4f9b5e..5bb5db11ec 100644 --- a/services/attachment/attachment_test.go +++ b/services/attachment/attachment_test.go @@ -10,7 +10,6 @@ import ( "testing" "code.gitea.io/gitea/models" - "code.gitea.io/gitea/models/db" "code.gitea.io/gitea/models/unittest" "github.com/stretchr/testify/assert" @@ -23,7 +22,7 @@ func TestMain(m *testing.M) { func TestUploadAttachment(t *testing.T) { assert.NoError(t, unittest.PrepareTestDatabase()) - user := db.AssertExistsAndLoadBean(t, &models.User{ID: 1}).(*models.User) + user := unittest.AssertExistsAndLoadBean(t, &models.User{ID: 1}).(*models.User) fPath := "./attachment_test.go" f, err := os.Open(fPath) diff --git a/services/gitdiff/gitdiff_test.go b/services/gitdiff/gitdiff_test.go index 359e2e8c66..aefd396ebb 100644 --- a/services/gitdiff/gitdiff_test.go +++ b/services/gitdiff/gitdiff_test.go @@ -13,7 +13,6 @@ import ( "testing" "code.gitea.io/gitea/models" - "code.gitea.io/gitea/models/db" "code.gitea.io/gitea/models/unittest" "code.gitea.io/gitea/modules/git" "code.gitea.io/gitea/modules/highlight" @@ -496,8 +495,8 @@ func setupDefaultDiff() *Diff { func TestDiff_LoadComments(t *testing.T) { assert.NoError(t, unittest.PrepareTestDatabase()) - issue := db.AssertExistsAndLoadBean(t, &models.Issue{ID: 2}).(*models.Issue) - user := db.AssertExistsAndLoadBean(t, &models.User{ID: 1}).(*models.User) + issue := unittest.AssertExistsAndLoadBean(t, &models.Issue{ID: 2}).(*models.Issue) + user := unittest.AssertExistsAndLoadBean(t, &models.User{ID: 1}).(*models.User) diff := setupDefaultDiff() assert.NoError(t, diff.LoadComments(issue, user)) assert.Len(t, diff.Files[0].Sections[0].Lines[0].Comments, 2) diff --git a/services/issue/label_test.go b/services/issue/label_test.go index 758ef98b27..fa6ad613b6 100644 --- a/services/issue/label_test.go +++ b/services/issue/label_test.go @@ -8,7 +8,6 @@ import ( "testing" "code.gitea.io/gitea/models" - "code.gitea.io/gitea/models/db" "code.gitea.io/gitea/models/unittest" "github.com/stretchr/testify/assert" ) @@ -26,15 +25,15 @@ func TestIssue_AddLabels(t *testing.T) { } for _, test := range tests { assert.NoError(t, unittest.PrepareTestDatabase()) - issue := db.AssertExistsAndLoadBean(t, &models.Issue{ID: test.issueID}).(*models.Issue) + issue := unittest.AssertExistsAndLoadBean(t, &models.Issue{ID: test.issueID}).(*models.Issue) labels := make([]*models.Label, len(test.labelIDs)) for i, labelID := range test.labelIDs { - labels[i] = db.AssertExistsAndLoadBean(t, &models.Label{ID: labelID}).(*models.Label) + labels[i] = unittest.AssertExistsAndLoadBean(t, &models.Label{ID: labelID}).(*models.Label) } - doer := db.AssertExistsAndLoadBean(t, &models.User{ID: test.doerID}).(*models.User) + doer := unittest.AssertExistsAndLoadBean(t, &models.User{ID: test.doerID}).(*models.User) assert.NoError(t, AddLabels(issue, doer, labels)) for _, labelID := range test.labelIDs { - db.AssertExistsAndLoadBean(t, &models.IssueLabel{IssueID: test.issueID, LabelID: labelID}) + unittest.AssertExistsAndLoadBean(t, &models.IssueLabel{IssueID: test.issueID, LabelID: labelID}) } } } @@ -52,10 +51,10 @@ func TestIssue_AddLabel(t *testing.T) { } for _, test := range tests { assert.NoError(t, unittest.PrepareTestDatabase()) - issue := db.AssertExistsAndLoadBean(t, &models.Issue{ID: test.issueID}).(*models.Issue) - label := db.AssertExistsAndLoadBean(t, &models.Label{ID: test.labelID}).(*models.Label) - doer := db.AssertExistsAndLoadBean(t, &models.User{ID: test.doerID}).(*models.User) + issue := unittest.AssertExistsAndLoadBean(t, &models.Issue{ID: test.issueID}).(*models.Issue) + label := unittest.AssertExistsAndLoadBean(t, &models.Label{ID: test.labelID}).(*models.Label) + doer := unittest.AssertExistsAndLoadBean(t, &models.User{ID: test.doerID}).(*models.User) assert.NoError(t, AddLabel(issue, doer, label)) - db.AssertExistsAndLoadBean(t, &models.IssueLabel{IssueID: test.issueID, LabelID: test.labelID}) + unittest.AssertExistsAndLoadBean(t, &models.IssueLabel{IssueID: test.issueID, LabelID: test.labelID}) } } diff --git a/services/mailer/mail_test.go b/services/mailer/mail_test.go index aaa18681b8..94ff5a65ae 100644 --- a/services/mailer/mail_test.go +++ b/services/mailer/mail_test.go @@ -11,7 +11,6 @@ import ( texttmpl "text/template" "code.gitea.io/gitea/models" - "code.gitea.io/gitea/models/db" "code.gitea.io/gitea/models/unittest" "code.gitea.io/gitea/modules/setting" @@ -50,11 +49,11 @@ func prepareMailerTest(t *testing.T) (doer *models.User, repo *models.Repository setting.MailService = &mailService setting.Domain = "localhost" - doer = db.AssertExistsAndLoadBean(t, &models.User{ID: 2}).(*models.User) - repo = db.AssertExistsAndLoadBean(t, &models.Repository{ID: 1, Owner: doer}).(*models.Repository) - issue = db.AssertExistsAndLoadBean(t, &models.Issue{ID: 1, Repo: repo, Poster: doer}).(*models.Issue) + doer = unittest.AssertExistsAndLoadBean(t, &models.User{ID: 2}).(*models.User) + repo = unittest.AssertExistsAndLoadBean(t, &models.Repository{ID: 1, Owner: doer}).(*models.Repository) + issue = unittest.AssertExistsAndLoadBean(t, &models.Issue{ID: 1, Repo: repo, Poster: doer}).(*models.Issue) assert.NoError(t, issue.LoadRepo()) - comment = db.AssertExistsAndLoadBean(t, &models.Comment{ID: 2, Issue: issue}).(*models.Comment) + comment = unittest.AssertExistsAndLoadBean(t, &models.Comment{ID: 2, Issue: issue}).(*models.Comment) return } @@ -145,8 +144,8 @@ func TestTemplateSelection(t *testing.T) { Content: "test body", Comment: comment}, recipients, false, "TestTemplateSelection") expect(t, msg, "issue/default/subject", "issue/default/body") - pull := db.AssertExistsAndLoadBean(t, &models.Issue{ID: 2, Repo: repo, Poster: doer}).(*models.Issue) - comment = db.AssertExistsAndLoadBean(t, &models.Comment{ID: 4, Issue: pull}).(*models.Comment) + pull := unittest.AssertExistsAndLoadBean(t, &models.Issue{ID: 2, Repo: repo, Poster: doer}).(*models.Issue) + comment = unittest.AssertExistsAndLoadBean(t, &models.Comment{ID: 4, Issue: pull}).(*models.Comment) msg = testComposeIssueCommentMessage(t, &mailCommentContext{Issue: pull, Doer: doer, ActionType: models.ActionCommentPull, Content: "test body", Comment: comment}, recipients, false, "TestTemplateSelection") expect(t, msg, "pull/comment/subject", "pull/comment/body") diff --git a/services/pull/check_test.go b/services/pull/check_test.go index bc3df0a4bb..f0ec096ea9 100644 --- a/services/pull/check_test.go +++ b/services/pull/check_test.go @@ -11,7 +11,6 @@ import ( "time" "code.gitea.io/gitea/models" - "code.gitea.io/gitea/models/db" "code.gitea.io/gitea/models/unittest" "code.gitea.io/gitea/modules/queue" @@ -43,11 +42,11 @@ func TestPullRequest_AddToTaskQueue(t *testing.T) { prQueue = q.(queue.UniqueQueue) - pr := db.AssertExistsAndLoadBean(t, &models.PullRequest{ID: 2}).(*models.PullRequest) + pr := unittest.AssertExistsAndLoadBean(t, &models.PullRequest{ID: 2}).(*models.PullRequest) AddToTaskQueue(pr) assert.Eventually(t, func() bool { - pr = db.AssertExistsAndLoadBean(t, &models.PullRequest{ID: 2}).(*models.PullRequest) + pr = unittest.AssertExistsAndLoadBean(t, &models.PullRequest{ID: 2}).(*models.PullRequest) return pr.Status == models.PullRequestStatusChecking }, 1*time.Second, 100*time.Millisecond) @@ -72,7 +71,7 @@ func TestPullRequest_AddToTaskQueue(t *testing.T) { assert.False(t, has) assert.NoError(t, err) - pr = db.AssertExistsAndLoadBean(t, &models.PullRequest{ID: 2}).(*models.PullRequest) + pr = unittest.AssertExistsAndLoadBean(t, &models.PullRequest{ID: 2}).(*models.PullRequest) assert.Equal(t, models.PullRequestStatusChecking, pr.Status) for _, callback := range queueShutdown { diff --git a/services/release/release_test.go b/services/release/release_test.go index b855ec6647..d720bf996b 100644 --- a/services/release/release_test.go +++ b/services/release/release_test.go @@ -11,7 +11,6 @@ import ( "time" "code.gitea.io/gitea/models" - "code.gitea.io/gitea/models/db" "code.gitea.io/gitea/models/unittest" "code.gitea.io/gitea/modules/git" "code.gitea.io/gitea/services/attachment" @@ -26,8 +25,8 @@ func TestMain(m *testing.M) { func TestRelease_Create(t *testing.T) { assert.NoError(t, unittest.PrepareTestDatabase()) - user := db.AssertExistsAndLoadBean(t, &models.User{ID: 2}).(*models.User) - repo := db.AssertExistsAndLoadBean(t, &models.Repository{ID: 1}).(*models.Repository) + user := unittest.AssertExistsAndLoadBean(t, &models.User{ID: 2}).(*models.User) + repo := unittest.AssertExistsAndLoadBean(t, &models.Repository{ID: 1}).(*models.Repository) repoPath := models.RepoPath(user.Name, repo.Name) gitRepo, err := git.OpenRepository(repoPath) @@ -130,8 +129,8 @@ func TestRelease_Create(t *testing.T) { func TestRelease_Update(t *testing.T) { assert.NoError(t, unittest.PrepareTestDatabase()) - user := db.AssertExistsAndLoadBean(t, &models.User{ID: 2}).(*models.User) - repo := db.AssertExistsAndLoadBean(t, &models.Repository{ID: 1}).(*models.Repository) + user := unittest.AssertExistsAndLoadBean(t, &models.User{ID: 2}).(*models.User) + repo := unittest.AssertExistsAndLoadBean(t, &models.Repository{ID: 1}).(*models.Repository) repoPath := models.RepoPath(user.Name, repo.Name) gitRepo, err := git.OpenRepository(repoPath) @@ -272,8 +271,8 @@ func TestRelease_Update(t *testing.T) { func TestRelease_createTag(t *testing.T) { assert.NoError(t, unittest.PrepareTestDatabase()) - user := db.AssertExistsAndLoadBean(t, &models.User{ID: 2}).(*models.User) - repo := db.AssertExistsAndLoadBean(t, &models.Repository{ID: 1}).(*models.Repository) + user := unittest.AssertExistsAndLoadBean(t, &models.User{ID: 2}).(*models.User) + repo := unittest.AssertExistsAndLoadBean(t, &models.Repository{ID: 1}).(*models.Repository) repoPath := models.RepoPath(user.Name, repo.Name) gitRepo, err := git.OpenRepository(repoPath) @@ -354,8 +353,8 @@ func TestRelease_createTag(t *testing.T) { func TestCreateNewTag(t *testing.T) { assert.NoError(t, unittest.PrepareTestDatabase()) - user := db.AssertExistsAndLoadBean(t, &models.User{ID: 2}).(*models.User) - repo := db.AssertExistsAndLoadBean(t, &models.Repository{ID: 1}).(*models.Repository) + user := unittest.AssertExistsAndLoadBean(t, &models.User{ID: 2}).(*models.User) + repo := unittest.AssertExistsAndLoadBean(t, &models.Repository{ID: 1}).(*models.Repository) assert.NoError(t, CreateNewTag(user, repo, "master", "v2.0", "v2.0 is released \n\n BUGFIX: .... \n\n 123")) diff --git a/services/repository/transfer_test.go b/services/repository/transfer_test.go index 9ce60f30ee..09c9829216 100644 --- a/services/repository/transfer_test.go +++ b/services/repository/transfer_test.go @@ -9,7 +9,6 @@ import ( "testing" "code.gitea.io/gitea/models" - "code.gitea.io/gitea/models/db" "code.gitea.io/gitea/models/unittest" "code.gitea.io/gitea/modules/notification" "code.gitea.io/gitea/modules/notification/action" @@ -31,12 +30,12 @@ func TestTransferOwnership(t *testing.T) { assert.NoError(t, unittest.PrepareTestDatabase()) - doer := db.AssertExistsAndLoadBean(t, &models.User{ID: 2}).(*models.User) - repo := db.AssertExistsAndLoadBean(t, &models.Repository{ID: 3}).(*models.Repository) - repo.Owner = db.AssertExistsAndLoadBean(t, &models.User{ID: repo.OwnerID}).(*models.User) + doer := unittest.AssertExistsAndLoadBean(t, &models.User{ID: 2}).(*models.User) + repo := unittest.AssertExistsAndLoadBean(t, &models.Repository{ID: 3}).(*models.Repository) + repo.Owner = unittest.AssertExistsAndLoadBean(t, &models.User{ID: repo.OwnerID}).(*models.User) assert.NoError(t, TransferOwnership(doer, doer, repo, nil)) - transferredRepo := db.AssertExistsAndLoadBean(t, &models.Repository{ID: 3}).(*models.Repository) + transferredRepo := unittest.AssertExistsAndLoadBean(t, &models.Repository{ID: 3}).(*models.Repository) assert.EqualValues(t, 2, transferredRepo.OwnerID) exist, err := util.IsExist(models.RepoPath("user3", "repo3")) @@ -45,23 +44,23 @@ func TestTransferOwnership(t *testing.T) { exist, err = util.IsExist(models.RepoPath("user2", "repo3")) assert.NoError(t, err) assert.True(t, exist) - db.AssertExistsAndLoadBean(t, &models.Action{ + unittest.AssertExistsAndLoadBean(t, &models.Action{ OpType: models.ActionTransferRepo, ActUserID: 2, RepoID: 3, Content: "user3/repo3", }) - models.CheckConsistencyFor(t, &models.Repository{}, &models.User{}, &models.Team{}) + unittest.CheckConsistencyFor(t, &models.Repository{}, &models.User{}, &models.Team{}) } func TestStartRepositoryTransferSetPermission(t *testing.T) { assert.NoError(t, unittest.PrepareTestDatabase()) - doer := db.AssertExistsAndLoadBean(t, &models.User{ID: 3}).(*models.User) - recipient := db.AssertExistsAndLoadBean(t, &models.User{ID: 5}).(*models.User) - repo := db.AssertExistsAndLoadBean(t, &models.Repository{ID: 3}).(*models.Repository) - repo.Owner = db.AssertExistsAndLoadBean(t, &models.User{ID: repo.OwnerID}).(*models.User) + doer := unittest.AssertExistsAndLoadBean(t, &models.User{ID: 3}).(*models.User) + recipient := unittest.AssertExistsAndLoadBean(t, &models.User{ID: 5}).(*models.User) + repo := unittest.AssertExistsAndLoadBean(t, &models.Repository{ID: 3}).(*models.Repository) + repo.Owner = unittest.AssertExistsAndLoadBean(t, &models.User{ID: repo.OwnerID}).(*models.User) hasAccess, err := models.HasAccess(recipient.ID, repo) assert.NoError(t, err) @@ -73,5 +72,5 @@ func TestStartRepositoryTransferSetPermission(t *testing.T) { assert.NoError(t, err) assert.True(t, hasAccess) - models.CheckConsistencyFor(t, &models.Repository{}, &models.User{}, &models.Team{}) + unittest.CheckConsistencyFor(t, &models.Repository{}, &models.User{}, &models.Team{}) } diff --git a/services/webhook/webhook_test.go b/services/webhook/webhook_test.go index 276d1e78cd..0a649d36ae 100644 --- a/services/webhook/webhook_test.go +++ b/services/webhook/webhook_test.go @@ -8,7 +8,6 @@ import ( "testing" "code.gitea.io/gitea/models" - "code.gitea.io/gitea/models/db" "code.gitea.io/gitea/models/unittest" webhook_model "code.gitea.io/gitea/models/webhook" api "code.gitea.io/gitea/modules/structs" @@ -30,50 +29,50 @@ func TestWebhook_GetSlackHook(t *testing.T) { func TestPrepareWebhooks(t *testing.T) { assert.NoError(t, unittest.PrepareTestDatabase()) - repo := db.AssertExistsAndLoadBean(t, &models.Repository{ID: 1}).(*models.Repository) + repo := unittest.AssertExistsAndLoadBean(t, &models.Repository{ID: 1}).(*models.Repository) hookTasks := []*webhook_model.HookTask{ {RepoID: repo.ID, HookID: 1, EventType: webhook_model.HookEventPush}, } for _, hookTask := range hookTasks { - db.AssertNotExistsBean(t, hookTask) + unittest.AssertNotExistsBean(t, hookTask) } assert.NoError(t, PrepareWebhooks(repo, webhook_model.HookEventPush, &api.PushPayload{Commits: []*api.PayloadCommit{{}}})) for _, hookTask := range hookTasks { - db.AssertExistsAndLoadBean(t, hookTask) + unittest.AssertExistsAndLoadBean(t, hookTask) } } func TestPrepareWebhooksBranchFilterMatch(t *testing.T) { assert.NoError(t, unittest.PrepareTestDatabase()) - repo := db.AssertExistsAndLoadBean(t, &models.Repository{ID: 2}).(*models.Repository) + repo := unittest.AssertExistsAndLoadBean(t, &models.Repository{ID: 2}).(*models.Repository) hookTasks := []*webhook_model.HookTask{ {RepoID: repo.ID, HookID: 4, EventType: webhook_model.HookEventPush}, } for _, hookTask := range hookTasks { - db.AssertNotExistsBean(t, hookTask) + unittest.AssertNotExistsBean(t, hookTask) } // this test also ensures that * doesn't handle / in any special way (like shell would) assert.NoError(t, PrepareWebhooks(repo, webhook_model.HookEventPush, &api.PushPayload{Ref: "refs/heads/feature/7791", Commits: []*api.PayloadCommit{{}}})) for _, hookTask := range hookTasks { - db.AssertExistsAndLoadBean(t, hookTask) + unittest.AssertExistsAndLoadBean(t, hookTask) } } func TestPrepareWebhooksBranchFilterNoMatch(t *testing.T) { assert.NoError(t, unittest.PrepareTestDatabase()) - repo := db.AssertExistsAndLoadBean(t, &models.Repository{ID: 2}).(*models.Repository) + repo := unittest.AssertExistsAndLoadBean(t, &models.Repository{ID: 2}).(*models.Repository) hookTasks := []*webhook_model.HookTask{ {RepoID: repo.ID, HookID: 4, EventType: webhook_model.HookEventPush}, } for _, hookTask := range hookTasks { - db.AssertNotExistsBean(t, hookTask) + unittest.AssertNotExistsBean(t, hookTask) } assert.NoError(t, PrepareWebhooks(repo, webhook_model.HookEventPush, &api.PushPayload{Ref: "refs/heads/fix_weird_bug"})) for _, hookTask := range hookTasks { - db.AssertNotExistsBean(t, hookTask) + unittest.AssertNotExistsBean(t, hookTask) } } diff --git a/services/wiki/wiki_test.go b/services/wiki/wiki_test.go index 7ecd3bb04e..ee548d2315 100644 --- a/services/wiki/wiki_test.go +++ b/services/wiki/wiki_test.go @@ -10,7 +10,6 @@ import ( "testing" "code.gitea.io/gitea/models" - "code.gitea.io/gitea/models/db" "code.gitea.io/gitea/models/unittest" "code.gitea.io/gitea/modules/git" "code.gitea.io/gitea/modules/util" @@ -113,11 +112,11 @@ func TestWikiNameToFilenameToName(t *testing.T) { func TestRepository_InitWiki(t *testing.T) { unittest.PrepareTestEnv(t) // repo1 already has a wiki - repo1 := db.AssertExistsAndLoadBean(t, &models.Repository{ID: 1}).(*models.Repository) + repo1 := unittest.AssertExistsAndLoadBean(t, &models.Repository{ID: 1}).(*models.Repository) assert.NoError(t, InitWiki(repo1)) // repo2 does not already have a wiki - repo2 := db.AssertExistsAndLoadBean(t, &models.Repository{ID: 2}).(*models.Repository) + repo2 := unittest.AssertExistsAndLoadBean(t, &models.Repository{ID: 2}).(*models.Repository) assert.NoError(t, InitWiki(repo2)) assert.True(t, repo2.HasWiki()) } @@ -126,8 +125,8 @@ func TestRepository_AddWikiPage(t *testing.T) { assert.NoError(t, unittest.PrepareTestDatabase()) const wikiContent = "This is the wiki content" const commitMsg = "Commit message" - repo := db.AssertExistsAndLoadBean(t, &models.Repository{ID: 1}).(*models.Repository) - doer := db.AssertExistsAndLoadBean(t, &models.User{ID: 2}).(*models.User) + repo := unittest.AssertExistsAndLoadBean(t, &models.Repository{ID: 1}).(*models.Repository) + doer := unittest.AssertExistsAndLoadBean(t, &models.User{ID: 2}).(*models.User) for _, wikiName := range []string{ "Another page", "Here's a <tag> and a/slash", @@ -171,8 +170,8 @@ func TestRepository_EditWikiPage(t *testing.T) { const newWikiContent = "This is the new content" const commitMsg = "Commit message" - repo := db.AssertExistsAndLoadBean(t, &models.Repository{ID: 1}).(*models.Repository) - doer := db.AssertExistsAndLoadBean(t, &models.User{ID: 2}).(*models.User) + repo := unittest.AssertExistsAndLoadBean(t, &models.Repository{ID: 1}).(*models.Repository) + doer := unittest.AssertExistsAndLoadBean(t, &models.User{ID: 2}).(*models.User) for _, newWikiName := range []string{ "Home", // same name as before "New home", @@ -201,8 +200,8 @@ func TestRepository_EditWikiPage(t *testing.T) { func TestRepository_DeleteWikiPage(t *testing.T) { unittest.PrepareTestEnv(t) - repo := db.AssertExistsAndLoadBean(t, &models.Repository{ID: 1}).(*models.Repository) - doer := db.AssertExistsAndLoadBean(t, &models.User{ID: 2}).(*models.User) + repo := unittest.AssertExistsAndLoadBean(t, &models.Repository{ID: 1}).(*models.Repository) + doer := unittest.AssertExistsAndLoadBean(t, &models.User{ID: 2}).(*models.User) assert.NoError(t, DeleteWikiPage(doer, repo, "Home")) // Now need to show that the page has been added: @@ -218,7 +217,7 @@ func TestRepository_DeleteWikiPage(t *testing.T) { func TestPrepareWikiFileName(t *testing.T) { unittest.PrepareTestEnv(t) - repo := db.AssertExistsAndLoadBean(t, &models.Repository{ID: 1}).(*models.Repository) + repo := unittest.AssertExistsAndLoadBean(t, &models.Repository{ID: 1}).(*models.Repository) gitRepo, err := git.OpenRepository(repo.WikiPath()) defer gitRepo.Close() assert.NoError(t, err) |