@@ -10,6 +10,7 @@ import (
10
10
11
11
issues_model "code.gitea.io/gitea/models/issues"
12
12
"code.gitea.io/gitea/models/unittest"
13
+ "code.gitea.io/gitea/modules/contexttest"
13
14
"code.gitea.io/gitea/modules/repository"
14
15
"code.gitea.io/gitea/modules/test"
15
16
"code.gitea.io/gitea/modules/web"
@@ -32,9 +33,9 @@ func int64SliceToCommaSeparated(a []int64) string {
32
33
func TestInitializeLabels (t * testing.T ) {
33
34
unittest .PrepareTestEnv (t )
34
35
assert .NoError (t , repository .LoadRepoConfig ())
35
- ctx , _ := test .MockContext (t , "user2/repo1/labels/initialize" )
36
- test .LoadUser (t , ctx , 2 )
37
- test .LoadRepo (t , ctx , 2 )
36
+ ctx , _ := contexttest .MockContext (t , "user2/repo1/labels/initialize" )
37
+ contexttest .LoadUser (t , ctx , 2 )
38
+ contexttest .LoadRepo (t , ctx , 2 )
38
39
web .SetForm (ctx , & forms.InitializeLabelsForm {TemplateName : "Default" })
39
40
InitializeLabels (ctx )
40
41
assert .EqualValues (t , http .StatusSeeOther , ctx .Resp .Status ())
@@ -57,9 +58,9 @@ func TestRetrieveLabels(t *testing.T) {
57
58
{1 , "leastissues" , []int64 {2 , 1 }},
58
59
{2 , "" , []int64 {}},
59
60
} {
60
- ctx , _ := test .MockContext (t , "user/repo/issues" )
61
- test .LoadUser (t , ctx , 2 )
62
- test .LoadRepo (t , ctx , testCase .RepoID )
61
+ ctx , _ := contexttest .MockContext (t , "user/repo/issues" )
62
+ contexttest .LoadUser (t , ctx , 2 )
63
+ contexttest .LoadRepo (t , ctx , testCase .RepoID )
63
64
ctx .Req .Form .Set ("sort" , testCase .Sort )
64
65
RetrieveLabels (ctx )
65
66
assert .False (t , ctx .Written ())
@@ -75,9 +76,9 @@ func TestRetrieveLabels(t *testing.T) {
75
76
76
77
func TestNewLabel (t * testing.T ) {
77
78
unittest .PrepareTestEnv (t )
78
- ctx , _ := test .MockContext (t , "user2/repo1/labels/edit" )
79
- test .LoadUser (t , ctx , 2 )
80
- test .LoadRepo (t , ctx , 1 )
79
+ ctx , _ := contexttest .MockContext (t , "user2/repo1/labels/edit" )
80
+ contexttest .LoadUser (t , ctx , 2 )
81
+ contexttest .LoadRepo (t , ctx , 1 )
81
82
web .SetForm (ctx , & forms.CreateLabelForm {
82
83
Title : "newlabel" ,
83
84
Color : "#abcdef" ,
@@ -93,9 +94,9 @@ func TestNewLabel(t *testing.T) {
93
94
94
95
func TestUpdateLabel (t * testing.T ) {
95
96
unittest .PrepareTestEnv (t )
96
- ctx , _ := test .MockContext (t , "user2/repo1/labels/edit" )
97
- test .LoadUser (t , ctx , 2 )
98
- test .LoadRepo (t , ctx , 1 )
97
+ ctx , _ := contexttest .MockContext (t , "user2/repo1/labels/edit" )
98
+ contexttest .LoadUser (t , ctx , 2 )
99
+ contexttest .LoadRepo (t , ctx , 1 )
99
100
web .SetForm (ctx , & forms.CreateLabelForm {
100
101
ID : 2 ,
101
102
Title : "newnameforlabel" ,
@@ -114,9 +115,9 @@ func TestUpdateLabel(t *testing.T) {
114
115
115
116
func TestDeleteLabel (t * testing.T ) {
116
117
unittest .PrepareTestEnv (t )
117
- ctx , _ := test .MockContext (t , "user2/repo1/labels/delete" )
118
- test .LoadUser (t , ctx , 2 )
119
- test .LoadRepo (t , ctx , 1 )
118
+ ctx , _ := contexttest .MockContext (t , "user2/repo1/labels/delete" )
119
+ contexttest .LoadUser (t , ctx , 2 )
120
+ contexttest .LoadRepo (t , ctx , 1 )
120
121
ctx .Req .Form .Set ("id" , "2" )
121
122
DeleteLabel (ctx )
122
123
assert .EqualValues (t , http .StatusOK , ctx .Resp .Status ())
@@ -127,9 +128,9 @@ func TestDeleteLabel(t *testing.T) {
127
128
128
129
func TestUpdateIssueLabel_Clear (t * testing.T ) {
129
130
unittest .PrepareTestEnv (t )
130
- ctx , _ := test .MockContext (t , "user2/repo1/issues/labels" )
131
- test .LoadUser (t , ctx , 2 )
132
- test .LoadRepo (t , ctx , 1 )
131
+ ctx , _ := contexttest .MockContext (t , "user2/repo1/issues/labels" )
132
+ contexttest .LoadUser (t , ctx , 2 )
133
+ contexttest .LoadRepo (t , ctx , 1 )
133
134
ctx .Req .Form .Set ("issue_ids" , "1,3" )
134
135
ctx .Req .Form .Set ("action" , "clear" )
135
136
UpdateIssueLabel (ctx )
@@ -152,9 +153,9 @@ func TestUpdateIssueLabel_Toggle(t *testing.T) {
152
153
{"toggle" , []int64 {1 , 2 }, 2 , true },
153
154
} {
154
155
unittest .PrepareTestEnv (t )
155
- ctx , _ := test .MockContext (t , "user2/repo1/issues/labels" )
156
- test .LoadUser (t , ctx , 2 )
157
- test .LoadRepo (t , ctx , 1 )
156
+ ctx , _ := contexttest .MockContext (t , "user2/repo1/issues/labels" )
157
+ contexttest .LoadUser (t , ctx , 2 )
158
+ contexttest .LoadRepo (t , ctx , 1 )
158
159
ctx .Req .Form .Set ("issue_ids" , int64SliceToCommaSeparated (testCase .IssueIDs ))
159
160
ctx .Req .Form .Set ("action" , testCase .Action )
160
161
ctx .Req .Form .Set ("id" , strconv .Itoa (int (testCase .LabelID )))
0 commit comments