mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2025-06-17 11:59:30 +00:00
Move db related basic functions to models/db (#17075)
* Move db related basic functions to models/db * Fix lint * Fix lint * Fix test * Fix lint * Fix lint * revert unnecessary change * Fix test * Fix wrong replace string * Use *Context * Correct committer spelling and fix wrong replaced words Co-authored-by: zeripath <art27@cantab.net>
This commit is contained in:
parent
462306e263
commit
a4bfef265d
335 changed files with 4191 additions and 3654 deletions
|
@ -14,6 +14,7 @@ import (
|
|||
"strings"
|
||||
|
||||
"code.gitea.io/gitea/models"
|
||||
"code.gitea.io/gitea/models/db"
|
||||
"code.gitea.io/gitea/modules/git"
|
||||
"code.gitea.io/gitea/modules/graceful"
|
||||
"code.gitea.io/gitea/modules/log"
|
||||
|
@ -97,11 +98,11 @@ func (aReq *ArchiveRequest) GetArchiveName() string {
|
|||
}
|
||||
|
||||
func doArchive(r *ArchiveRequest) (*models.RepoArchiver, error) {
|
||||
ctx, commiter, err := models.TxDBContext()
|
||||
ctx, committer, err := db.TxContext()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer commiter.Close()
|
||||
defer committer.Close()
|
||||
|
||||
archiver, err := models.GetRepoArchiver(ctx, r.RepoID, r.Type, r.CommitID)
|
||||
if err != nil {
|
||||
|
@ -206,7 +207,7 @@ func doArchive(r *ArchiveRequest) (*models.RepoArchiver, error) {
|
|||
}
|
||||
}
|
||||
|
||||
return archiver, commiter.Commit()
|
||||
return archiver, committer.Commit()
|
||||
}
|
||||
|
||||
// ArchiveRepository satisfies the ArchiveRequest being passed in. Processing
|
||||
|
|
|
@ -9,14 +9,14 @@ import (
|
|||
"testing"
|
||||
"time"
|
||||
|
||||
"code.gitea.io/gitea/models"
|
||||
"code.gitea.io/gitea/models/db"
|
||||
"code.gitea.io/gitea/modules/test"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestMain(m *testing.M) {
|
||||
models.MainTest(m, filepath.Join("..", ".."))
|
||||
db.MainTest(m, filepath.Join("..", ".."))
|
||||
}
|
||||
|
||||
func waitForCount(t *testing.T, num int) {
|
||||
|
@ -24,7 +24,7 @@ func waitForCount(t *testing.T, num int) {
|
|||
}
|
||||
|
||||
func TestArchive_Basic(t *testing.T) {
|
||||
assert.NoError(t, models.PrepareTestDatabase())
|
||||
assert.NoError(t, db.PrepareTestDatabase())
|
||||
|
||||
ctx := test.MockContext(t, "user27/repo49")
|
||||
firstCommit, secondCommit := "51f84af23134", "aacbdfe9e1c4"
|
||||
|
|
|
@ -10,6 +10,7 @@ import (
|
|||
"io"
|
||||
|
||||
"code.gitea.io/gitea/models"
|
||||
"code.gitea.io/gitea/models/db"
|
||||
"code.gitea.io/gitea/modules/storage"
|
||||
"code.gitea.io/gitea/modules/upload"
|
||||
|
||||
|
@ -22,7 +23,7 @@ func NewAttachment(attach *models.Attachment, file io.Reader) (*models.Attachmen
|
|||
return nil, fmt.Errorf("attachment %s should belong to a repository", attach.Name)
|
||||
}
|
||||
|
||||
err := models.WithTx(func(ctx models.DBContext) error {
|
||||
err := db.WithTx(func(ctx *db.Context) error {
|
||||
attach.UUID = uuid.New().String()
|
||||
size, err := storage.Attachments.Save(attach.RelativePath(), file, -1)
|
||||
if err != nil {
|
||||
|
@ -30,7 +31,7 @@ func NewAttachment(attach *models.Attachment, file io.Reader) (*models.Attachmen
|
|||
}
|
||||
attach.Size = size
|
||||
|
||||
return models.Insert(ctx, attach)
|
||||
return db.Insert(ctx, attach)
|
||||
})
|
||||
|
||||
return attach, err
|
||||
|
|
|
@ -10,18 +10,19 @@ import (
|
|||
"testing"
|
||||
|
||||
"code.gitea.io/gitea/models"
|
||||
"code.gitea.io/gitea/models/db"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestMain(m *testing.M) {
|
||||
models.MainTest(m, filepath.Join("..", ".."))
|
||||
db.MainTest(m, filepath.Join("..", ".."))
|
||||
}
|
||||
|
||||
func TestUploadAttachment(t *testing.T) {
|
||||
assert.NoError(t, models.PrepareTestDatabase())
|
||||
assert.NoError(t, db.PrepareTestDatabase())
|
||||
|
||||
user := models.AssertExistsAndLoadBean(t, &models.User{ID: 1}).(*models.User)
|
||||
user := db.AssertExistsAndLoadBean(t, &models.User{ID: 1}).(*models.User)
|
||||
|
||||
fPath := "./attachment_test.go"
|
||||
f, err := os.Open(fPath)
|
||||
|
|
|
@ -8,6 +8,7 @@ import (
|
|||
"net/http"
|
||||
|
||||
"code.gitea.io/gitea/models"
|
||||
"code.gitea.io/gitea/models/db"
|
||||
)
|
||||
|
||||
// Ensure the struct implements the interface.
|
||||
|
@ -60,7 +61,7 @@ func (b *Group) Free() error {
|
|||
|
||||
// Verify extracts and validates
|
||||
func (b *Group) Verify(req *http.Request, w http.ResponseWriter, store DataStore, sess SessionStore) *models.User {
|
||||
if !models.HasEngine {
|
||||
if !db.HasEngine {
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
|
@ -11,6 +11,7 @@ import (
|
|||
"time"
|
||||
|
||||
"code.gitea.io/gitea/models"
|
||||
"code.gitea.io/gitea/models/db"
|
||||
"code.gitea.io/gitea/modules/log"
|
||||
"code.gitea.io/gitea/modules/timeutil"
|
||||
"code.gitea.io/gitea/modules/web/middleware"
|
||||
|
@ -109,7 +110,7 @@ func (o *OAuth2) userIDFromToken(req *http.Request, store DataStore) int64 {
|
|||
// If verification is successful returns an existing user object.
|
||||
// Returns nil if verification fails.
|
||||
func (o *OAuth2) Verify(req *http.Request, w http.ResponseWriter, store DataStore, sess SessionStore) *models.User {
|
||||
if !models.HasEngine {
|
||||
if !db.HasEngine {
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
|
@ -8,6 +8,7 @@ import (
|
|||
"strings"
|
||||
|
||||
"code.gitea.io/gitea/models"
|
||||
"code.gitea.io/gitea/models/db"
|
||||
"code.gitea.io/gitea/modules/log"
|
||||
|
||||
// Register the sources
|
||||
|
@ -25,7 +26,7 @@ func UserSignIn(username, password string) (*models.User, *models.LoginSource, e
|
|||
if strings.Contains(username, "@") {
|
||||
user = &models.User{Email: strings.ToLower(strings.TrimSpace(username))}
|
||||
// check same email
|
||||
cnt, err := models.Count(user)
|
||||
cnt, err := db.Count(user)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
|
|
|
@ -9,6 +9,7 @@ import (
|
|||
"sync"
|
||||
|
||||
"code.gitea.io/gitea/models"
|
||||
"code.gitea.io/gitea/models/db"
|
||||
"code.gitea.io/gitea/modules/log"
|
||||
"code.gitea.io/gitea/modules/setting"
|
||||
|
||||
|
@ -33,7 +34,7 @@ func Init() error {
|
|||
return err
|
||||
}
|
||||
|
||||
store, err := models.CreateStore(SessionTableName, UsersStoreKey)
|
||||
store, err := db.CreateStore(SessionTableName, UsersStoreKey)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
|
@ -6,6 +6,7 @@ package comments
|
|||
|
||||
import (
|
||||
"code.gitea.io/gitea/models"
|
||||
"code.gitea.io/gitea/models/db"
|
||||
"code.gitea.io/gitea/modules/notification"
|
||||
)
|
||||
|
||||
|
@ -22,7 +23,7 @@ func CreateIssueComment(doer *models.User, repo *models.Repository, issue *model
|
|||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
mentions, err := issue.FindAndUpdateIssueMentions(models.DefaultDBContext(), doer, comment.Content)
|
||||
mentions, err := issue.FindAndUpdateIssueMentions(db.DefaultContext(), doer, comment.Content)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
|
@ -23,6 +23,7 @@ import (
|
|||
"time"
|
||||
|
||||
"code.gitea.io/gitea/models"
|
||||
"code.gitea.io/gitea/models/db"
|
||||
"code.gitea.io/gitea/modules/analyze"
|
||||
"code.gitea.io/gitea/modules/charset"
|
||||
"code.gitea.io/gitea/modules/git"
|
||||
|
@ -1122,7 +1123,7 @@ func parseHunks(curFile *DiffFile, maxLines, maxLineCharacters int, input *bufio
|
|||
oid := strings.TrimPrefix(line[1:], lfs.MetaFileOidPrefix)
|
||||
if len(oid) == 64 {
|
||||
m := &models.LFSMetaObject{Pointer: lfs.Pointer{Oid: oid}}
|
||||
count, err := models.Count(m)
|
||||
count, err := db.Count(m)
|
||||
|
||||
if err == nil && count > 0 {
|
||||
curFile.IsBin = true
|
||||
|
|
|
@ -13,6 +13,7 @@ import (
|
|||
"testing"
|
||||
|
||||
"code.gitea.io/gitea/models"
|
||||
"code.gitea.io/gitea/models/db"
|
||||
"code.gitea.io/gitea/modules/git"
|
||||
"code.gitea.io/gitea/modules/highlight"
|
||||
"code.gitea.io/gitea/modules/json"
|
||||
|
@ -492,10 +493,10 @@ func setupDefaultDiff() *Diff {
|
|||
}
|
||||
}
|
||||
func TestDiff_LoadComments(t *testing.T) {
|
||||
assert.NoError(t, models.PrepareTestDatabase())
|
||||
assert.NoError(t, db.PrepareTestDatabase())
|
||||
|
||||
issue := models.AssertExistsAndLoadBean(t, &models.Issue{ID: 2}).(*models.Issue)
|
||||
user := models.AssertExistsAndLoadBean(t, &models.User{ID: 1}).(*models.User)
|
||||
issue := db.AssertExistsAndLoadBean(t, &models.Issue{ID: 2}).(*models.Issue)
|
||||
user := db.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,9 +8,9 @@ import (
|
|||
"path/filepath"
|
||||
"testing"
|
||||
|
||||
"code.gitea.io/gitea/models"
|
||||
"code.gitea.io/gitea/models/db"
|
||||
)
|
||||
|
||||
func TestMain(m *testing.M) {
|
||||
models.MainTest(m, filepath.Join("..", ".."))
|
||||
db.MainTest(m, filepath.Join("..", ".."))
|
||||
}
|
||||
|
|
|
@ -8,11 +8,12 @@ import (
|
|||
"testing"
|
||||
|
||||
"code.gitea.io/gitea/models"
|
||||
"code.gitea.io/gitea/models/db"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestDeleteNotPassedAssignee(t *testing.T) {
|
||||
assert.NoError(t, models.PrepareTestDatabase())
|
||||
assert.NoError(t, db.PrepareTestDatabase())
|
||||
|
||||
// Fake issue with assignees
|
||||
issue, err := models.GetIssueWithAttrsByID(1)
|
||||
|
|
|
@ -6,6 +6,7 @@ package issue
|
|||
|
||||
import (
|
||||
"code.gitea.io/gitea/models"
|
||||
"code.gitea.io/gitea/models/db"
|
||||
"code.gitea.io/gitea/modules/git"
|
||||
"code.gitea.io/gitea/modules/notification"
|
||||
"code.gitea.io/gitea/modules/util"
|
||||
|
@ -23,7 +24,7 @@ func NewIssue(repo *models.Repository, issue *models.Issue, labelIDs []int64, uu
|
|||
}
|
||||
}
|
||||
|
||||
mentions, err := issue.FindAndUpdateIssueMentions(models.DefaultDBContext(), issue.Poster, issue.Content)
|
||||
mentions, err := issue.FindAndUpdateIssueMentions(db.DefaultContext(), issue.Poster, issue.Content)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
|
@ -8,6 +8,7 @@ import (
|
|||
"testing"
|
||||
|
||||
"code.gitea.io/gitea/models"
|
||||
"code.gitea.io/gitea/models/db"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
|
@ -23,16 +24,16 @@ func TestIssue_AddLabels(t *testing.T) {
|
|||
{2, []int64{}, 1}, // pull-request, empty
|
||||
}
|
||||
for _, test := range tests {
|
||||
assert.NoError(t, models.PrepareTestDatabase())
|
||||
issue := models.AssertExistsAndLoadBean(t, &models.Issue{ID: test.issueID}).(*models.Issue)
|
||||
assert.NoError(t, db.PrepareTestDatabase())
|
||||
issue := db.AssertExistsAndLoadBean(t, &models.Issue{ID: test.issueID}).(*models.Issue)
|
||||
labels := make([]*models.Label, len(test.labelIDs))
|
||||
for i, labelID := range test.labelIDs {
|
||||
labels[i] = models.AssertExistsAndLoadBean(t, &models.Label{ID: labelID}).(*models.Label)
|
||||
labels[i] = db.AssertExistsAndLoadBean(t, &models.Label{ID: labelID}).(*models.Label)
|
||||
}
|
||||
doer := models.AssertExistsAndLoadBean(t, &models.User{ID: test.doerID}).(*models.User)
|
||||
doer := db.AssertExistsAndLoadBean(t, &models.User{ID: test.doerID}).(*models.User)
|
||||
assert.NoError(t, AddLabels(issue, doer, labels))
|
||||
for _, labelID := range test.labelIDs {
|
||||
models.AssertExistsAndLoadBean(t, &models.IssueLabel{IssueID: test.issueID, LabelID: labelID})
|
||||
db.AssertExistsAndLoadBean(t, &models.IssueLabel{IssueID: test.issueID, LabelID: labelID})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -49,11 +50,11 @@ func TestIssue_AddLabel(t *testing.T) {
|
|||
{2, 1, 2}, // pull-request, already-added label
|
||||
}
|
||||
for _, test := range tests {
|
||||
assert.NoError(t, models.PrepareTestDatabase())
|
||||
issue := models.AssertExistsAndLoadBean(t, &models.Issue{ID: test.issueID}).(*models.Issue)
|
||||
label := models.AssertExistsAndLoadBean(t, &models.Label{ID: test.labelID}).(*models.Label)
|
||||
doer := models.AssertExistsAndLoadBean(t, &models.User{ID: test.doerID}).(*models.User)
|
||||
assert.NoError(t, db.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)
|
||||
assert.NoError(t, AddLabel(issue, doer, label))
|
||||
models.AssertExistsAndLoadBean(t, &models.IssueLabel{IssueID: test.issueID, LabelID: test.labelID})
|
||||
db.AssertExistsAndLoadBean(t, &models.IssueLabel{IssueID: test.issueID, LabelID: test.labelID})
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,9 +8,9 @@ import (
|
|||
"path/filepath"
|
||||
"testing"
|
||||
|
||||
"code.gitea.io/gitea/models"
|
||||
"code.gitea.io/gitea/models/db"
|
||||
)
|
||||
|
||||
func TestMain(m *testing.M) {
|
||||
models.MainTest(m, filepath.Join("..", ".."))
|
||||
db.MainTest(m, filepath.Join("..", ".."))
|
||||
}
|
||||
|
|
|
@ -11,6 +11,7 @@ import (
|
|||
texttmpl "text/template"
|
||||
|
||||
"code.gitea.io/gitea/models"
|
||||
"code.gitea.io/gitea/models/db"
|
||||
"code.gitea.io/gitea/modules/setting"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
|
@ -40,7 +41,7 @@ const bodyTpl = `
|
|||
`
|
||||
|
||||
func prepareMailerTest(t *testing.T) (doer *models.User, repo *models.Repository, issue *models.Issue, comment *models.Comment) {
|
||||
assert.NoError(t, models.PrepareTestDatabase())
|
||||
assert.NoError(t, db.PrepareTestDatabase())
|
||||
var mailService = setting.Mailer{
|
||||
From: "test@gitea.com",
|
||||
}
|
||||
|
@ -48,11 +49,11 @@ func prepareMailerTest(t *testing.T) (doer *models.User, repo *models.Repository
|
|||
setting.MailService = &mailService
|
||||
setting.Domain = "localhost"
|
||||
|
||||
doer = models.AssertExistsAndLoadBean(t, &models.User{ID: 2}).(*models.User)
|
||||
repo = models.AssertExistsAndLoadBean(t, &models.Repository{ID: 1, Owner: doer}).(*models.Repository)
|
||||
issue = models.AssertExistsAndLoadBean(t, &models.Issue{ID: 1, Repo: repo, Poster: doer}).(*models.Issue)
|
||||
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)
|
||||
assert.NoError(t, issue.LoadRepo())
|
||||
comment = models.AssertExistsAndLoadBean(t, &models.Comment{ID: 2, Issue: issue}).(*models.Comment)
|
||||
comment = db.AssertExistsAndLoadBean(t, &models.Comment{ID: 2, Issue: issue}).(*models.Comment)
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -139,8 +140,8 @@ func TestTemplateSelection(t *testing.T) {
|
|||
Content: "test body", Comment: comment}, recipients, false, "TestTemplateSelection")
|
||||
expect(t, msg, "issue/default/subject", "issue/default/body")
|
||||
|
||||
pull := models.AssertExistsAndLoadBean(t, &models.Issue{ID: 2, Repo: repo, Poster: doer}).(*models.Issue)
|
||||
comment = models.AssertExistsAndLoadBean(t, &models.Comment{ID: 4, Issue: pull}).(*models.Comment)
|
||||
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)
|
||||
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")
|
||||
|
|
|
@ -8,9 +8,9 @@ import (
|
|||
"path/filepath"
|
||||
"testing"
|
||||
|
||||
"code.gitea.io/gitea/models"
|
||||
"code.gitea.io/gitea/models/db"
|
||||
)
|
||||
|
||||
func TestMain(m *testing.M) {
|
||||
models.MainTest(m, filepath.Join("..", ".."))
|
||||
db.MainTest(m, filepath.Join("..", ".."))
|
||||
}
|
||||
|
|
|
@ -11,6 +11,7 @@ import (
|
|||
"time"
|
||||
|
||||
"code.gitea.io/gitea/models"
|
||||
"code.gitea.io/gitea/models/db"
|
||||
"code.gitea.io/gitea/modules/cache"
|
||||
"code.gitea.io/gitea/modules/git"
|
||||
"code.gitea.io/gitea/modules/lfs"
|
||||
|
@ -203,7 +204,7 @@ func runSync(ctx context.Context, m *models.Mirror) ([]*mirrorSyncResult, bool)
|
|||
gitRepo.Close()
|
||||
|
||||
log.Trace("SyncMirrors [repo: %-v]: updating size of repository", m.Repo)
|
||||
if err := m.Repo.UpdateSize(models.DefaultDBContext()); err != nil {
|
||||
if err := m.Repo.UpdateSize(db.DefaultContext()); err != nil {
|
||||
log.Error("Failed to update size for mirror repository: %v", err)
|
||||
}
|
||||
|
||||
|
|
|
@ -11,13 +11,14 @@ import (
|
|||
"time"
|
||||
|
||||
"code.gitea.io/gitea/models"
|
||||
"code.gitea.io/gitea/models/db"
|
||||
"code.gitea.io/gitea/modules/queue"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestPullRequest_AddToTaskQueue(t *testing.T) {
|
||||
assert.NoError(t, models.PrepareTestDatabase())
|
||||
assert.NoError(t, db.PrepareTestDatabase())
|
||||
|
||||
idChan := make(chan int64, 10)
|
||||
|
||||
|
@ -41,11 +42,11 @@ func TestPullRequest_AddToTaskQueue(t *testing.T) {
|
|||
|
||||
prQueue = q.(queue.UniqueQueue)
|
||||
|
||||
pr := models.AssertExistsAndLoadBean(t, &models.PullRequest{ID: 2}).(*models.PullRequest)
|
||||
pr := db.AssertExistsAndLoadBean(t, &models.PullRequest{ID: 2}).(*models.PullRequest)
|
||||
AddToTaskQueue(pr)
|
||||
|
||||
assert.Eventually(t, func() bool {
|
||||
pr = models.AssertExistsAndLoadBean(t, &models.PullRequest{ID: 2}).(*models.PullRequest)
|
||||
pr = db.AssertExistsAndLoadBean(t, &models.PullRequest{ID: 2}).(*models.PullRequest)
|
||||
return pr.Status == models.PullRequestStatusChecking
|
||||
}, 1*time.Second, 100*time.Millisecond)
|
||||
|
||||
|
@ -70,7 +71,7 @@ func TestPullRequest_AddToTaskQueue(t *testing.T) {
|
|||
assert.False(t, has)
|
||||
assert.NoError(t, err)
|
||||
|
||||
pr = models.AssertExistsAndLoadBean(t, &models.PullRequest{ID: 2}).(*models.PullRequest)
|
||||
pr = db.AssertExistsAndLoadBean(t, &models.PullRequest{ID: 2}).(*models.PullRequest)
|
||||
assert.Equal(t, models.PullRequestStatusChecking, pr.Status)
|
||||
|
||||
for _, callback := range queueShutdown {
|
||||
|
|
|
@ -9,9 +9,9 @@ import (
|
|||
"path/filepath"
|
||||
"testing"
|
||||
|
||||
"code.gitea.io/gitea/models"
|
||||
"code.gitea.io/gitea/models/db"
|
||||
)
|
||||
|
||||
func TestMain(m *testing.M) {
|
||||
models.MainTest(m, filepath.Join("..", ".."))
|
||||
db.MainTest(m, filepath.Join("..", ".."))
|
||||
}
|
||||
|
|
|
@ -14,6 +14,7 @@ import (
|
|||
"time"
|
||||
|
||||
"code.gitea.io/gitea/models"
|
||||
"code.gitea.io/gitea/models/db"
|
||||
"code.gitea.io/gitea/modules/git"
|
||||
"code.gitea.io/gitea/modules/graceful"
|
||||
"code.gitea.io/gitea/modules/json"
|
||||
|
@ -58,7 +59,7 @@ func NewPullRequest(repo *models.Repository, pull *models.Issue, labelIDs []int6
|
|||
return err
|
||||
}
|
||||
|
||||
mentions, err := pull.FindAndUpdateIssueMentions(models.DefaultDBContext(), pull.Poster, pull.Content)
|
||||
mentions, err := pull.FindAndUpdateIssueMentions(db.DefaultContext(), pull.Poster, pull.Content)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
|
@ -12,6 +12,7 @@ import (
|
|||
"strings"
|
||||
|
||||
"code.gitea.io/gitea/models"
|
||||
"code.gitea.io/gitea/models/db"
|
||||
"code.gitea.io/gitea/modules/git"
|
||||
"code.gitea.io/gitea/modules/log"
|
||||
"code.gitea.io/gitea/modules/notification"
|
||||
|
@ -58,7 +59,7 @@ func CreateCodeComment(doer *models.User, gitRepo *git.Repository, issue *models
|
|||
return nil, err
|
||||
}
|
||||
|
||||
mentions, err := issue.FindAndUpdateIssueMentions(models.DefaultDBContext(), doer, comment.Content)
|
||||
mentions, err := issue.FindAndUpdateIssueMentions(db.DefaultContext(), doer, comment.Content)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -245,7 +246,7 @@ func SubmitReview(doer *models.User, gitRepo *git.Repository, issue *models.Issu
|
|||
return nil, nil, err
|
||||
}
|
||||
|
||||
ctx := models.DefaultDBContext()
|
||||
ctx := db.DefaultContext()
|
||||
mentions, err := issue.FindAndUpdateIssueMentions(ctx, doer, comm.Content)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
|
|
|
@ -10,6 +10,7 @@ import (
|
|||
"strings"
|
||||
|
||||
"code.gitea.io/gitea/models"
|
||||
"code.gitea.io/gitea/models/db"
|
||||
"code.gitea.io/gitea/modules/git"
|
||||
"code.gitea.io/gitea/modules/log"
|
||||
"code.gitea.io/gitea/modules/notification"
|
||||
|
@ -122,7 +123,7 @@ func CreateRelease(gitRepo *git.Repository, rel *models.Release, attachmentUUIDs
|
|||
return err
|
||||
}
|
||||
|
||||
if err = models.AddReleaseAttachments(models.DefaultDBContext(), rel.ID, attachmentUUIDs); err != nil {
|
||||
if err = models.AddReleaseAttachments(db.DefaultContext(), rel.ID, attachmentUUIDs); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
|
@ -188,11 +189,11 @@ func UpdateRelease(doer *models.User, gitRepo *git.Repository, rel *models.Relea
|
|||
}
|
||||
rel.LowerTagName = strings.ToLower(rel.TagName)
|
||||
|
||||
ctx, commiter, err := models.TxDBContext()
|
||||
ctx, committer, err := db.TxContext()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer commiter.Close()
|
||||
defer committer.Close()
|
||||
|
||||
if err = models.UpdateRelease(ctx, rel); err != nil {
|
||||
return err
|
||||
|
@ -249,7 +250,7 @@ func UpdateRelease(doer *models.User, gitRepo *git.Repository, rel *models.Relea
|
|||
}
|
||||
}
|
||||
|
||||
if err = commiter.Commit(); err != nil {
|
||||
if err = committer.Commit(); err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -310,7 +311,7 @@ func DeleteReleaseByID(id int64, doer *models.User, delTag bool) error {
|
|||
} else {
|
||||
rel.IsTag = true
|
||||
|
||||
if err = models.UpdateRelease(models.DefaultDBContext(), rel); err != nil {
|
||||
if err = models.UpdateRelease(db.DefaultContext(), rel); err != nil {
|
||||
return fmt.Errorf("Update: %v", err)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,6 +11,7 @@ import (
|
|||
"time"
|
||||
|
||||
"code.gitea.io/gitea/models"
|
||||
"code.gitea.io/gitea/models/db"
|
||||
"code.gitea.io/gitea/modules/git"
|
||||
"code.gitea.io/gitea/services/attachment"
|
||||
|
||||
|
@ -18,14 +19,14 @@ import (
|
|||
)
|
||||
|
||||
func TestMain(m *testing.M) {
|
||||
models.MainTest(m, filepath.Join("..", ".."))
|
||||
db.MainTest(m, filepath.Join("..", ".."))
|
||||
}
|
||||
|
||||
func TestRelease_Create(t *testing.T) {
|
||||
assert.NoError(t, models.PrepareTestDatabase())
|
||||
assert.NoError(t, db.PrepareTestDatabase())
|
||||
|
||||
user := models.AssertExistsAndLoadBean(t, &models.User{ID: 2}).(*models.User)
|
||||
repo := models.AssertExistsAndLoadBean(t, &models.Repository{ID: 1}).(*models.Repository)
|
||||
user := db.AssertExistsAndLoadBean(t, &models.User{ID: 2}).(*models.User)
|
||||
repo := db.AssertExistsAndLoadBean(t, &models.Repository{ID: 1}).(*models.Repository)
|
||||
repoPath := models.RepoPath(user.Name, repo.Name)
|
||||
|
||||
gitRepo, err := git.OpenRepository(repoPath)
|
||||
|
@ -126,10 +127,10 @@ func TestRelease_Create(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestRelease_Update(t *testing.T) {
|
||||
assert.NoError(t, models.PrepareTestDatabase())
|
||||
assert.NoError(t, db.PrepareTestDatabase())
|
||||
|
||||
user := models.AssertExistsAndLoadBean(t, &models.User{ID: 2}).(*models.User)
|
||||
repo := models.AssertExistsAndLoadBean(t, &models.Repository{ID: 1}).(*models.Repository)
|
||||
user := db.AssertExistsAndLoadBean(t, &models.User{ID: 2}).(*models.User)
|
||||
repo := db.AssertExistsAndLoadBean(t, &models.Repository{ID: 1}).(*models.Repository)
|
||||
repoPath := models.RepoPath(user.Name, repo.Name)
|
||||
|
||||
gitRepo, err := git.OpenRepository(repoPath)
|
||||
|
@ -268,10 +269,10 @@ func TestRelease_Update(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestRelease_createTag(t *testing.T) {
|
||||
assert.NoError(t, models.PrepareTestDatabase())
|
||||
assert.NoError(t, db.PrepareTestDatabase())
|
||||
|
||||
user := models.AssertExistsAndLoadBean(t, &models.User{ID: 2}).(*models.User)
|
||||
repo := models.AssertExistsAndLoadBean(t, &models.Repository{ID: 1}).(*models.Repository)
|
||||
user := db.AssertExistsAndLoadBean(t, &models.User{ID: 2}).(*models.User)
|
||||
repo := db.AssertExistsAndLoadBean(t, &models.Repository{ID: 1}).(*models.Repository)
|
||||
repoPath := models.RepoPath(user.Name, repo.Name)
|
||||
|
||||
gitRepo, err := git.OpenRepository(repoPath)
|
||||
|
@ -351,9 +352,9 @@ func TestRelease_createTag(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestCreateNewTag(t *testing.T) {
|
||||
assert.NoError(t, models.PrepareTestDatabase())
|
||||
user := models.AssertExistsAndLoadBean(t, &models.User{ID: 2}).(*models.User)
|
||||
repo := models.AssertExistsAndLoadBean(t, &models.Repository{ID: 1}).(*models.Repository)
|
||||
assert.NoError(t, db.PrepareTestDatabase())
|
||||
user := db.AssertExistsAndLoadBean(t, &models.User{ID: 2}).(*models.User)
|
||||
repo := db.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"))
|
||||
|
|
|
@ -6,6 +6,7 @@ package repository
|
|||
|
||||
import (
|
||||
"code.gitea.io/gitea/models"
|
||||
"code.gitea.io/gitea/models/db"
|
||||
"code.gitea.io/gitea/modules/log"
|
||||
"code.gitea.io/gitea/modules/notification"
|
||||
repo_module "code.gitea.io/gitea/modules/repository"
|
||||
|
@ -20,7 +21,7 @@ func GenerateRepository(doer, owner *models.User, templateRepo *models.Repositor
|
|||
}
|
||||
|
||||
var generateRepo *models.Repository
|
||||
if err = models.WithTx(func(ctx models.DBContext) error {
|
||||
if err = db.WithTx(func(ctx *db.Context) error {
|
||||
generateRepo, err = repo_module.GenerateRepository(ctx, doer, owner, templateRepo, opts)
|
||||
if err != nil {
|
||||
return err
|
||||
|
|
|
@ -8,9 +8,9 @@ import (
|
|||
"path/filepath"
|
||||
"testing"
|
||||
|
||||
"code.gitea.io/gitea/models"
|
||||
"code.gitea.io/gitea/models/db"
|
||||
)
|
||||
|
||||
func TestMain(m *testing.M) {
|
||||
models.MainTest(m, filepath.Join("..", ".."))
|
||||
db.MainTest(m, filepath.Join("..", ".."))
|
||||
}
|
||||
|
|
|
@ -9,6 +9,7 @@ import (
|
|||
"time"
|
||||
|
||||
"code.gitea.io/gitea/models"
|
||||
"code.gitea.io/gitea/models/db"
|
||||
"code.gitea.io/gitea/modules/cache"
|
||||
"code.gitea.io/gitea/modules/git"
|
||||
"code.gitea.io/gitea/modules/graceful"
|
||||
|
@ -82,7 +83,7 @@ func pushUpdates(optsList []*repo_module.PushUpdateOptions) error {
|
|||
}
|
||||
defer gitRepo.Close()
|
||||
|
||||
if err = repo.UpdateSize(models.DefaultDBContext()); err != nil {
|
||||
if err = repo.UpdateSize(db.DefaultContext()); err != nil {
|
||||
log.Error("Failed to update size for repository: %v", err)
|
||||
}
|
||||
|
||||
|
|
|
@ -9,6 +9,7 @@ import (
|
|||
"testing"
|
||||
|
||||
"code.gitea.io/gitea/models"
|
||||
"code.gitea.io/gitea/models/db"
|
||||
"code.gitea.io/gitea/modules/notification"
|
||||
"code.gitea.io/gitea/modules/notification/action"
|
||||
"code.gitea.io/gitea/modules/util"
|
||||
|
@ -27,14 +28,14 @@ func registerNotifier() {
|
|||
func TestTransferOwnership(t *testing.T) {
|
||||
registerNotifier()
|
||||
|
||||
assert.NoError(t, models.PrepareTestDatabase())
|
||||
assert.NoError(t, db.PrepareTestDatabase())
|
||||
|
||||
doer := models.AssertExistsAndLoadBean(t, &models.User{ID: 2}).(*models.User)
|
||||
repo := models.AssertExistsAndLoadBean(t, &models.Repository{ID: 3}).(*models.Repository)
|
||||
repo.Owner = models.AssertExistsAndLoadBean(t, &models.User{ID: repo.OwnerID}).(*models.User)
|
||||
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)
|
||||
assert.NoError(t, TransferOwnership(doer, doer, repo, nil))
|
||||
|
||||
transferredRepo := models.AssertExistsAndLoadBean(t, &models.Repository{ID: 3}).(*models.Repository)
|
||||
transferredRepo := db.AssertExistsAndLoadBean(t, &models.Repository{ID: 3}).(*models.Repository)
|
||||
assert.EqualValues(t, 2, transferredRepo.OwnerID)
|
||||
|
||||
exist, err := util.IsExist(models.RepoPath("user3", "repo3"))
|
||||
|
@ -43,7 +44,7 @@ func TestTransferOwnership(t *testing.T) {
|
|||
exist, err = util.IsExist(models.RepoPath("user2", "repo3"))
|
||||
assert.NoError(t, err)
|
||||
assert.True(t, exist)
|
||||
models.AssertExistsAndLoadBean(t, &models.Action{
|
||||
db.AssertExistsAndLoadBean(t, &models.Action{
|
||||
OpType: models.ActionTransferRepo,
|
||||
ActUserID: 2,
|
||||
RepoID: 3,
|
||||
|
@ -54,12 +55,12 @@ func TestTransferOwnership(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestStartRepositoryTransferSetPermission(t *testing.T) {
|
||||
assert.NoError(t, models.PrepareTestDatabase())
|
||||
assert.NoError(t, db.PrepareTestDatabase())
|
||||
|
||||
doer := models.AssertExistsAndLoadBean(t, &models.User{ID: 3}).(*models.User)
|
||||
recipient := models.AssertExistsAndLoadBean(t, &models.User{ID: 5}).(*models.User)
|
||||
repo := models.AssertExistsAndLoadBean(t, &models.Repository{ID: 3}).(*models.Repository)
|
||||
repo.Owner = models.AssertExistsAndLoadBean(t, &models.User{ID: repo.OwnerID}).(*models.User)
|
||||
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)
|
||||
|
||||
hasAccess, err := models.HasAccess(recipient.ID, repo)
|
||||
assert.NoError(t, err)
|
||||
|
|
|
@ -8,9 +8,9 @@ import (
|
|||
"path/filepath"
|
||||
"testing"
|
||||
|
||||
"code.gitea.io/gitea/models"
|
||||
"code.gitea.io/gitea/models/db"
|
||||
)
|
||||
|
||||
func TestMain(m *testing.M) {
|
||||
models.MainTest(m, filepath.Join("..", ".."))
|
||||
db.MainTest(m, filepath.Join("..", ".."))
|
||||
}
|
||||
|
|
|
@ -8,6 +8,7 @@ import (
|
|||
"testing"
|
||||
|
||||
"code.gitea.io/gitea/models"
|
||||
"code.gitea.io/gitea/models/db"
|
||||
api "code.gitea.io/gitea/modules/structs"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
@ -25,52 +26,52 @@ func TestWebhook_GetSlackHook(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestPrepareWebhooks(t *testing.T) {
|
||||
assert.NoError(t, models.PrepareTestDatabase())
|
||||
assert.NoError(t, db.PrepareTestDatabase())
|
||||
|
||||
repo := models.AssertExistsAndLoadBean(t, &models.Repository{ID: 1}).(*models.Repository)
|
||||
repo := db.AssertExistsAndLoadBean(t, &models.Repository{ID: 1}).(*models.Repository)
|
||||
hookTasks := []*models.HookTask{
|
||||
{RepoID: repo.ID, HookID: 1, EventType: models.HookEventPush},
|
||||
}
|
||||
for _, hookTask := range hookTasks {
|
||||
models.AssertNotExistsBean(t, hookTask)
|
||||
db.AssertNotExistsBean(t, hookTask)
|
||||
}
|
||||
assert.NoError(t, PrepareWebhooks(repo, models.HookEventPush, &api.PushPayload{Commits: []*api.PayloadCommit{{}}}))
|
||||
for _, hookTask := range hookTasks {
|
||||
models.AssertExistsAndLoadBean(t, hookTask)
|
||||
db.AssertExistsAndLoadBean(t, hookTask)
|
||||
}
|
||||
}
|
||||
|
||||
func TestPrepareWebhooksBranchFilterMatch(t *testing.T) {
|
||||
assert.NoError(t, models.PrepareTestDatabase())
|
||||
assert.NoError(t, db.PrepareTestDatabase())
|
||||
|
||||
repo := models.AssertExistsAndLoadBean(t, &models.Repository{ID: 2}).(*models.Repository)
|
||||
repo := db.AssertExistsAndLoadBean(t, &models.Repository{ID: 2}).(*models.Repository)
|
||||
hookTasks := []*models.HookTask{
|
||||
{RepoID: repo.ID, HookID: 4, EventType: models.HookEventPush},
|
||||
}
|
||||
for _, hookTask := range hookTasks {
|
||||
models.AssertNotExistsBean(t, hookTask)
|
||||
db.AssertNotExistsBean(t, hookTask)
|
||||
}
|
||||
// this test also ensures that * doesn't handle / in any special way (like shell would)
|
||||
assert.NoError(t, PrepareWebhooks(repo, models.HookEventPush, &api.PushPayload{Ref: "refs/heads/feature/7791", Commits: []*api.PayloadCommit{{}}}))
|
||||
for _, hookTask := range hookTasks {
|
||||
models.AssertExistsAndLoadBean(t, hookTask)
|
||||
db.AssertExistsAndLoadBean(t, hookTask)
|
||||
}
|
||||
}
|
||||
|
||||
func TestPrepareWebhooksBranchFilterNoMatch(t *testing.T) {
|
||||
assert.NoError(t, models.PrepareTestDatabase())
|
||||
assert.NoError(t, db.PrepareTestDatabase())
|
||||
|
||||
repo := models.AssertExistsAndLoadBean(t, &models.Repository{ID: 2}).(*models.Repository)
|
||||
repo := db.AssertExistsAndLoadBean(t, &models.Repository{ID: 2}).(*models.Repository)
|
||||
hookTasks := []*models.HookTask{
|
||||
{RepoID: repo.ID, HookID: 4, EventType: models.HookEventPush},
|
||||
}
|
||||
for _, hookTask := range hookTasks {
|
||||
models.AssertNotExistsBean(t, hookTask)
|
||||
db.AssertNotExistsBean(t, hookTask)
|
||||
}
|
||||
assert.NoError(t, PrepareWebhooks(repo, models.HookEventPush, &api.PushPayload{Ref: "refs/heads/fix_weird_bug"}))
|
||||
|
||||
for _, hookTask := range hookTasks {
|
||||
models.AssertNotExistsBean(t, hookTask)
|
||||
db.AssertNotExistsBean(t, hookTask)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -11,6 +11,7 @@ import (
|
|||
"testing"
|
||||
|
||||
"code.gitea.io/gitea/models"
|
||||
"code.gitea.io/gitea/models/db"
|
||||
"code.gitea.io/gitea/modules/git"
|
||||
"code.gitea.io/gitea/modules/util"
|
||||
|
||||
|
@ -18,7 +19,7 @@ import (
|
|||
)
|
||||
|
||||
func TestMain(m *testing.M) {
|
||||
models.MainTest(m, filepath.Join("..", ".."))
|
||||
db.MainTest(m, filepath.Join("..", ".."))
|
||||
}
|
||||
|
||||
func TestWikiNameToSubURL(t *testing.T) {
|
||||
|
@ -110,23 +111,23 @@ func TestWikiNameToFilenameToName(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestRepository_InitWiki(t *testing.T) {
|
||||
models.PrepareTestEnv(t)
|
||||
db.PrepareTestEnv(t)
|
||||
// repo1 already has a wiki
|
||||
repo1 := models.AssertExistsAndLoadBean(t, &models.Repository{ID: 1}).(*models.Repository)
|
||||
repo1 := db.AssertExistsAndLoadBean(t, &models.Repository{ID: 1}).(*models.Repository)
|
||||
assert.NoError(t, InitWiki(repo1))
|
||||
|
||||
// repo2 does not already have a wiki
|
||||
repo2 := models.AssertExistsAndLoadBean(t, &models.Repository{ID: 2}).(*models.Repository)
|
||||
repo2 := db.AssertExistsAndLoadBean(t, &models.Repository{ID: 2}).(*models.Repository)
|
||||
assert.NoError(t, InitWiki(repo2))
|
||||
assert.True(t, repo2.HasWiki())
|
||||
}
|
||||
|
||||
func TestRepository_AddWikiPage(t *testing.T) {
|
||||
assert.NoError(t, models.PrepareTestDatabase())
|
||||
assert.NoError(t, db.PrepareTestDatabase())
|
||||
const wikiContent = "This is the wiki content"
|
||||
const commitMsg = "Commit message"
|
||||
repo := models.AssertExistsAndLoadBean(t, &models.Repository{ID: 1}).(*models.Repository)
|
||||
doer := models.AssertExistsAndLoadBean(t, &models.User{ID: 2}).(*models.User)
|
||||
repo := db.AssertExistsAndLoadBean(t, &models.Repository{ID: 1}).(*models.Repository)
|
||||
doer := db.AssertExistsAndLoadBean(t, &models.User{ID: 2}).(*models.User)
|
||||
for _, wikiName := range []string{
|
||||
"Another page",
|
||||
"Here's a <tag> and a/slash",
|
||||
|
@ -166,18 +167,18 @@ func TestRepository_AddWikiPage(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestRepository_EditWikiPage(t *testing.T) {
|
||||
assert.NoError(t, models.PrepareTestDatabase())
|
||||
assert.NoError(t, db.PrepareTestDatabase())
|
||||
|
||||
const newWikiContent = "This is the new content"
|
||||
const commitMsg = "Commit message"
|
||||
repo := models.AssertExistsAndLoadBean(t, &models.Repository{ID: 1}).(*models.Repository)
|
||||
doer := models.AssertExistsAndLoadBean(t, &models.User{ID: 2}).(*models.User)
|
||||
repo := db.AssertExistsAndLoadBean(t, &models.Repository{ID: 1}).(*models.Repository)
|
||||
doer := db.AssertExistsAndLoadBean(t, &models.User{ID: 2}).(*models.User)
|
||||
for _, newWikiName := range []string{
|
||||
"Home", // same name as before
|
||||
"New home",
|
||||
"New/name/with/slashes",
|
||||
} {
|
||||
models.PrepareTestEnv(t)
|
||||
db.PrepareTestEnv(t)
|
||||
assert.NoError(t, EditWikiPage(doer, repo, "Home", newWikiName, newWikiContent, commitMsg))
|
||||
|
||||
// Now need to show that the page has been added:
|
||||
|
@ -199,9 +200,9 @@ func TestRepository_EditWikiPage(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestRepository_DeleteWikiPage(t *testing.T) {
|
||||
models.PrepareTestEnv(t)
|
||||
repo := models.AssertExistsAndLoadBean(t, &models.Repository{ID: 1}).(*models.Repository)
|
||||
doer := models.AssertExistsAndLoadBean(t, &models.User{ID: 2}).(*models.User)
|
||||
db.PrepareTestEnv(t)
|
||||
repo := db.AssertExistsAndLoadBean(t, &models.Repository{ID: 1}).(*models.Repository)
|
||||
doer := db.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:
|
||||
|
@ -216,8 +217,8 @@ func TestRepository_DeleteWikiPage(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestPrepareWikiFileName(t *testing.T) {
|
||||
models.PrepareTestEnv(t)
|
||||
repo := models.AssertExistsAndLoadBean(t, &models.Repository{ID: 1}).(*models.Repository)
|
||||
db.PrepareTestEnv(t)
|
||||
repo := db.AssertExistsAndLoadBean(t, &models.Repository{ID: 1}).(*models.Repository)
|
||||
gitRepo, err := git.OpenRepository(repo.WikiPath())
|
||||
defer gitRepo.Close()
|
||||
assert.NoError(t, err)
|
||||
|
@ -267,7 +268,7 @@ func TestPrepareWikiFileName(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestPrepareWikiFileName_FirstPage(t *testing.T) {
|
||||
models.PrepareTestEnv(t)
|
||||
db.PrepareTestEnv(t)
|
||||
|
||||
// Now create a temporaryDirectory
|
||||
tmpDir, err := ioutil.TempDir("", "empty-wiki")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue