mirror of
https://codeberg.org/davrot/forgejo.git
synced 2025-05-20 14:00:04 +02:00
Decouple unit test code from business code (#17623)
This commit is contained in:
parent
7f802631c5
commit
df64fa4865
136 changed files with 1058 additions and 830 deletions
|
@ -9,13 +9,14 @@ import (
|
|||
"testing"
|
||||
|
||||
"code.gitea.io/gitea/models/db"
|
||||
"code.gitea.io/gitea/models/unittest"
|
||||
"code.gitea.io/gitea/modules/setting"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestRepository_WikiCloneLink(t *testing.T) {
|
||||
assert.NoError(t, db.PrepareTestDatabase())
|
||||
assert.NoError(t, unittest.PrepareTestDatabase())
|
||||
|
||||
repo := db.AssertExistsAndLoadBean(t, &Repository{ID: 1}).(*Repository)
|
||||
cloneLink := repo.WikiCloneLink()
|
||||
|
@ -24,20 +25,20 @@ func TestRepository_WikiCloneLink(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestWikiPath(t *testing.T) {
|
||||
assert.NoError(t, db.PrepareTestDatabase())
|
||||
assert.NoError(t, unittest.PrepareTestDatabase())
|
||||
expected := filepath.Join(setting.RepoRootPath, "user2/repo1.wiki.git")
|
||||
assert.Equal(t, expected, WikiPath("user2", "repo1"))
|
||||
}
|
||||
|
||||
func TestRepository_WikiPath(t *testing.T) {
|
||||
assert.NoError(t, db.PrepareTestDatabase())
|
||||
assert.NoError(t, unittest.PrepareTestDatabase())
|
||||
repo := db.AssertExistsAndLoadBean(t, &Repository{ID: 1}).(*Repository)
|
||||
expected := filepath.Join(setting.RepoRootPath, "user2/repo1.wiki.git")
|
||||
assert.Equal(t, expected, repo.WikiPath())
|
||||
}
|
||||
|
||||
func TestRepository_HasWiki(t *testing.T) {
|
||||
db.PrepareTestEnv(t)
|
||||
unittest.PrepareTestEnv(t)
|
||||
repo1 := db.AssertExistsAndLoadBean(t, &Repository{ID: 1}).(*Repository)
|
||||
assert.True(t, repo1.HasWiki())
|
||||
repo2 := db.AssertExistsAndLoadBean(t, &Repository{ID: 2}).(*Repository)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue