mirror of
https://github.com/go-gitea/gitea
synced 2025-07-22 18:28:37 +00:00
Decouple unit test, remove intermediate unittestbridge
package (#17662)
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
This commit is contained in:
@@ -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)
|
||||
|
@@ -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)
|
||||
|
@@ -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})
|
||||
}
|
||||
}
|
||||
|
@@ -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")
|
||||
|
@@ -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 {
|
||||
|
@@ -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"))
|
||||
|
@@ -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{})
|
||||
}
|
||||
|
@@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -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)
|
||||
|
Reference in New Issue
Block a user