mirror of
https://github.com/go-gitea/gitea
synced 2025-07-22 18:28:37 +00:00
Decouple unit test code from business code (#17623)
This commit is contained in:
@@ -9,7 +9,7 @@ import (
|
||||
"testing"
|
||||
|
||||
"code.gitea.io/gitea/models"
|
||||
"code.gitea.io/gitea/models/db"
|
||||
"code.gitea.io/gitea/models/unittest"
|
||||
"code.gitea.io/gitea/modules/setting"
|
||||
"code.gitea.io/gitea/modules/test"
|
||||
|
||||
@@ -19,7 +19,7 @@ import (
|
||||
func TestArchivedIssues(t *testing.T) {
|
||||
// Arrange
|
||||
setting.UI.IssuePagingNum = 1
|
||||
assert.NoError(t, db.LoadFixtures())
|
||||
assert.NoError(t, unittest.LoadFixtures())
|
||||
|
||||
ctx := test.MockContext(t, "issues")
|
||||
test.LoadUser(t, ctx, 30)
|
||||
@@ -52,7 +52,7 @@ func TestArchivedIssues(t *testing.T) {
|
||||
|
||||
func TestIssues(t *testing.T) {
|
||||
setting.UI.IssuePagingNum = 1
|
||||
assert.NoError(t, db.LoadFixtures())
|
||||
assert.NoError(t, unittest.LoadFixtures())
|
||||
|
||||
ctx := test.MockContext(t, "issues")
|
||||
test.LoadUser(t, ctx, 2)
|
||||
@@ -68,7 +68,7 @@ func TestIssues(t *testing.T) {
|
||||
|
||||
func TestPulls(t *testing.T) {
|
||||
setting.UI.IssuePagingNum = 20
|
||||
assert.NoError(t, db.LoadFixtures())
|
||||
assert.NoError(t, unittest.LoadFixtures())
|
||||
|
||||
ctx := test.MockContext(t, "pulls")
|
||||
test.LoadUser(t, ctx, 2)
|
||||
@@ -81,7 +81,7 @@ func TestPulls(t *testing.T) {
|
||||
|
||||
func TestMilestones(t *testing.T) {
|
||||
setting.UI.IssuePagingNum = 1
|
||||
assert.NoError(t, db.LoadFixtures())
|
||||
assert.NoError(t, unittest.LoadFixtures())
|
||||
|
||||
ctx := test.MockContext(t, "milestones")
|
||||
test.LoadUser(t, ctx, 2)
|
||||
@@ -100,7 +100,7 @@ func TestMilestones(t *testing.T) {
|
||||
|
||||
func TestMilestonesForSpecificRepo(t *testing.T) {
|
||||
setting.UI.IssuePagingNum = 1
|
||||
assert.NoError(t, db.LoadFixtures())
|
||||
assert.NoError(t, unittest.LoadFixtures())
|
||||
|
||||
ctx := test.MockContext(t, "milestones")
|
||||
test.LoadUser(t, ctx, 2)
|
||||
|
@@ -8,9 +8,9 @@ import (
|
||||
"path/filepath"
|
||||
"testing"
|
||||
|
||||
"code.gitea.io/gitea/models/db"
|
||||
"code.gitea.io/gitea/models/unittest"
|
||||
)
|
||||
|
||||
func TestMain(m *testing.M) {
|
||||
db.MainTest(m, filepath.Join("..", "..", ".."))
|
||||
unittest.MainTest(m, filepath.Join("..", "..", ".."))
|
||||
}
|
||||
|
@@ -10,6 +10,7 @@ import (
|
||||
"code.gitea.io/gitea/models"
|
||||
"code.gitea.io/gitea/models/db"
|
||||
"code.gitea.io/gitea/models/login"
|
||||
"code.gitea.io/gitea/models/unittest"
|
||||
"code.gitea.io/gitea/services/auth/source/oauth2"
|
||||
|
||||
"github.com/golang-jwt/jwt"
|
||||
@@ -41,7 +42,7 @@ func createAndParseToken(t *testing.T, grant *login.OAuth2Grant) *oauth2.OIDCTok
|
||||
}
|
||||
|
||||
func TestNewAccessTokenResponse_OIDCToken(t *testing.T) {
|
||||
assert.NoError(t, db.PrepareTestDatabase())
|
||||
assert.NoError(t, unittest.PrepareTestDatabase())
|
||||
|
||||
grants, err := login.GetOAuth2GrantsByUserID(3)
|
||||
assert.NoError(t, err)
|
||||
|
@@ -8,7 +8,7 @@ import (
|
||||
"net/http"
|
||||
"testing"
|
||||
|
||||
"code.gitea.io/gitea/models/db"
|
||||
"code.gitea.io/gitea/models/unittest"
|
||||
"code.gitea.io/gitea/modules/setting"
|
||||
"code.gitea.io/gitea/modules/test"
|
||||
"code.gitea.io/gitea/modules/web"
|
||||
@@ -81,7 +81,7 @@ func TestChangePassword(t *testing.T) {
|
||||
PasswordComplexity: pcLU,
|
||||
},
|
||||
} {
|
||||
db.PrepareTestEnv(t)
|
||||
unittest.PrepareTestEnv(t)
|
||||
ctx := test.MockContext(t, "user/settings/security")
|
||||
test.LoadUser(t, ctx, 2)
|
||||
test.LoadRepo(t, ctx, 1)
|
||||
|
@@ -8,9 +8,9 @@ import (
|
||||
"path/filepath"
|
||||
"testing"
|
||||
|
||||
"code.gitea.io/gitea/models/db"
|
||||
"code.gitea.io/gitea/models/unittest"
|
||||
)
|
||||
|
||||
func TestMain(m *testing.M) {
|
||||
db.MainTest(m, filepath.Join("..", "..", "..", ".."))
|
||||
unittest.MainTest(m, filepath.Join("..", "..", "..", ".."))
|
||||
}
|
||||
|
Reference in New Issue
Block a user