Decouple unit test code from business code (#17623)
This commit is contained in:
@@ -8,7 +8,8 @@ import (
|
||||
"path/filepath"
|
||||
"testing"
|
||||
|
||||
"code.gitea.io/gitea/models/db"
|
||||
"code.gitea.io/gitea/models/unittest"
|
||||
|
||||
api "code.gitea.io/gitea/modules/structs"
|
||||
"code.gitea.io/gitea/modules/test"
|
||||
|
||||
@@ -16,7 +17,7 @@ import (
|
||||
)
|
||||
|
||||
func TestMain(m *testing.M) {
|
||||
db.MainTest(m, filepath.Join("..", ".."))
|
||||
unittest.MainTest(m, filepath.Join("..", ".."))
|
||||
}
|
||||
|
||||
func getExpectedReadmeContentsResponse() *api.ContentsResponse {
|
||||
@@ -49,7 +50,7 @@ func getExpectedReadmeContentsResponse() *api.ContentsResponse {
|
||||
}
|
||||
|
||||
func TestGetContents(t *testing.T) {
|
||||
db.PrepareTestEnv(t)
|
||||
unittest.PrepareTestEnv(t)
|
||||
ctx := test.MockContext(t, "user2/repo1")
|
||||
ctx.SetParams(":id", "1")
|
||||
test.LoadRepo(t, ctx, 1)
|
||||
@@ -77,7 +78,7 @@ func TestGetContents(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestGetContentsOrListForDir(t *testing.T) {
|
||||
db.PrepareTestEnv(t)
|
||||
unittest.PrepareTestEnv(t)
|
||||
ctx := test.MockContext(t, "user2/repo1")
|
||||
ctx.SetParams(":id", "1")
|
||||
test.LoadRepo(t, ctx, 1)
|
||||
@@ -112,7 +113,7 @@ func TestGetContentsOrListForDir(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestGetContentsOrListForFile(t *testing.T) {
|
||||
db.PrepareTestEnv(t)
|
||||
unittest.PrepareTestEnv(t)
|
||||
ctx := test.MockContext(t, "user2/repo1")
|
||||
ctx.SetParams(":id", "1")
|
||||
test.LoadRepo(t, ctx, 1)
|
||||
@@ -140,7 +141,7 @@ func TestGetContentsOrListForFile(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestGetContentsErrors(t *testing.T) {
|
||||
db.PrepareTestEnv(t)
|
||||
unittest.PrepareTestEnv(t)
|
||||
ctx := test.MockContext(t, "user2/repo1")
|
||||
ctx.SetParams(":id", "1")
|
||||
test.LoadRepo(t, ctx, 1)
|
||||
@@ -171,7 +172,7 @@ func TestGetContentsErrors(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestGetContentsOrListErrors(t *testing.T) {
|
||||
db.PrepareTestEnv(t)
|
||||
unittest.PrepareTestEnv(t)
|
||||
ctx := test.MockContext(t, "user2/repo1")
|
||||
ctx.SetParams(":id", "1")
|
||||
test.LoadRepo(t, ctx, 1)
|
||||
@@ -202,7 +203,7 @@ func TestGetContentsOrListErrors(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestGetContentsOrListOfEmptyRepos(t *testing.T) {
|
||||
db.PrepareTestEnv(t)
|
||||
unittest.PrepareTestEnv(t)
|
||||
ctx := test.MockContext(t, "user2/repo15")
|
||||
ctx.SetParams(":id", "15")
|
||||
test.LoadRepo(t, ctx, 15)
|
||||
|
||||
Reference in New Issue
Block a user