diff options
author | wxiaoguang <wxiaoguang@gmail.com> | 2021-11-12 22:36:47 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-11-12 22:36:47 +0800 |
commit | df64fa486555de6f403a795fd16c2e9e1d59e535 (patch) | |
tree | b899e9b9e5d57409b1bf0e3afbd606b6a3900235 /routers/web/repo/settings_test.go | |
parent | 7f802631c54d2e91301158380b273b872d62bd80 (diff) | |
download | gitea-df64fa486555de6f403a795fd16c2e9e1d59e535.tar.gz gitea-df64fa486555de6f403a795fd16c2e9e1d59e535.zip |
Decouple unit test code from business code (#17623)
Diffstat (limited to 'routers/web/repo/settings_test.go')
-rw-r--r-- | routers/web/repo/settings_test.go | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/routers/web/repo/settings_test.go b/routers/web/repo/settings_test.go index a3ed271cce..78426f5b79 100644 --- a/routers/web/repo/settings_test.go +++ b/routers/web/repo/settings_test.go @@ -11,6 +11,7 @@ import ( "code.gitea.io/gitea/models" "code.gitea.io/gitea/models/db" + "code.gitea.io/gitea/models/unittest" "code.gitea.io/gitea/modules/context" "code.gitea.io/gitea/modules/setting" "code.gitea.io/gitea/modules/test" @@ -43,7 +44,7 @@ func TestAddReadOnlyDeployKey(t *testing.T) { } else { return } - db.PrepareTestEnv(t) + unittest.PrepareTestEnv(t) ctx := test.MockContext(t, "user2/repo1/settings/keys") @@ -72,7 +73,7 @@ func TestAddReadWriteOnlyDeployKey(t *testing.T) { return } - db.PrepareTestEnv(t) + unittest.PrepareTestEnv(t) ctx := test.MockContext(t, "user2/repo1/settings/keys") @@ -97,7 +98,7 @@ func TestAddReadWriteOnlyDeployKey(t *testing.T) { func TestCollaborationPost(t *testing.T) { - db.PrepareTestEnv(t) + unittest.PrepareTestEnv(t) ctx := test.MockContext(t, "user2/repo1/issues/labels") test.LoadUser(t, ctx, 2) test.LoadUser(t, ctx, 4) @@ -133,7 +134,7 @@ func TestCollaborationPost(t *testing.T) { func TestCollaborationPost_InactiveUser(t *testing.T) { - db.PrepareTestEnv(t) + unittest.PrepareTestEnv(t) ctx := test.MockContext(t, "user2/repo1/issues/labels") test.LoadUser(t, ctx, 2) test.LoadUser(t, ctx, 9) @@ -157,7 +158,7 @@ func TestCollaborationPost_InactiveUser(t *testing.T) { func TestCollaborationPost_AddCollaboratorTwice(t *testing.T) { - db.PrepareTestEnv(t) + unittest.PrepareTestEnv(t) ctx := test.MockContext(t, "user2/repo1/issues/labels") test.LoadUser(t, ctx, 2) test.LoadUser(t, ctx, 4) @@ -199,7 +200,7 @@ func TestCollaborationPost_AddCollaboratorTwice(t *testing.T) { func TestCollaborationPost_NonExistentUser(t *testing.T) { - db.PrepareTestEnv(t) + unittest.PrepareTestEnv(t) ctx := test.MockContext(t, "user2/repo1/issues/labels") test.LoadUser(t, ctx, 2) test.LoadRepo(t, ctx, 1) @@ -221,7 +222,7 @@ func TestCollaborationPost_NonExistentUser(t *testing.T) { } func TestAddTeamPost(t *testing.T) { - db.PrepareTestEnv(t) + unittest.PrepareTestEnv(t) ctx := test.MockContext(t, "org26/repo43") ctx.Req.Form.Set("team", "team11") @@ -261,7 +262,7 @@ func TestAddTeamPost(t *testing.T) { } func TestAddTeamPost_NotAllowed(t *testing.T) { - db.PrepareTestEnv(t) + unittest.PrepareTestEnv(t) ctx := test.MockContext(t, "org26/repo43") ctx.Req.Form.Set("team", "team11") @@ -302,7 +303,7 @@ func TestAddTeamPost_NotAllowed(t *testing.T) { } func TestAddTeamPost_AddTeamTwice(t *testing.T) { - db.PrepareTestEnv(t) + unittest.PrepareTestEnv(t) ctx := test.MockContext(t, "org26/repo43") ctx.Req.Form.Set("team", "team11") @@ -343,7 +344,7 @@ func TestAddTeamPost_AddTeamTwice(t *testing.T) { } func TestAddTeamPost_NonExistentTeam(t *testing.T) { - db.PrepareTestEnv(t) + unittest.PrepareTestEnv(t) ctx := test.MockContext(t, "org26/repo43") ctx.Req.Form.Set("team", "team-non-existent") @@ -376,7 +377,7 @@ func TestAddTeamPost_NonExistentTeam(t *testing.T) { } func TestDeleteTeam(t *testing.T) { - db.PrepareTestEnv(t) + unittest.PrepareTestEnv(t) ctx := test.MockContext(t, "org3/team1/repo3") ctx.Req.Form.Set("id", "2") |