@@ -15,9 +15,9 @@ import (
15
15
"github.com/stretchr/testify/assert"
16
16
)
17
17
18
- const AppURL = "http://localhost:3000/"
19
- const Repo = "gogits/gogs"
20
- const AppSubURL = AppURL + Repo + "/"
18
+ const TestAppURL = "http://localhost:3000/"
19
+ const TestOrgRepo = "gogits/gogs"
20
+ const TestRepoURL = TestAppURL + TestOrgRepo + "/"
21
21
22
22
// alphanumLink an HTML link to an alphanumeric-style issue
23
23
func alphanumIssueLink (baseURL , class , name string ) string {
@@ -52,7 +52,7 @@ var alphanumericMetas = map[string]string{
52
52
"style" : IssueNameStyleAlphanumeric ,
53
53
}
54
54
55
- // these values should match the Repo const above
55
+ // these values should match the TestOrgRepo const above
56
56
var localMetas = map [string ]string {
57
57
"user" : "gogits" ,
58
58
"repo" : "gogs" ,
@@ -90,8 +90,7 @@ func TestRender_IssueIndexPattern(t *testing.T) {
90
90
}
91
91
92
92
func TestRender_IssueIndexPattern2 (t * testing.T ) {
93
- setting .AppURL = AppURL
94
- setting .AppSubURL = AppSubURL
93
+ setting .AppURL = TestAppURL
95
94
96
95
// numeric: render inputs with valid mentions
97
96
test := func (s , expectedFmt , marker string , indices ... int ) {
@@ -108,7 +107,7 @@ func TestRender_IssueIndexPattern2(t *testing.T) {
108
107
109
108
links := make ([]interface {}, len (indices ))
110
109
for i , index := range indices {
111
- links [i ] = numericIssueLink (util .URLJoin (setting . AppSubURL , path ), "ref-issue" , index , marker )
110
+ links [i ] = numericIssueLink (util .URLJoin (TestRepoURL , path ), "ref-issue" , index , marker )
112
111
}
113
112
expectedNil := fmt .Sprintf (expectedFmt , links ... )
114
113
testRenderIssueIndexPattern (t , s , expectedNil , & RenderContext {Metas : localMetas })
@@ -152,8 +151,7 @@ func TestRender_IssueIndexPattern2(t *testing.T) {
152
151
}
153
152
154
153
func TestRender_IssueIndexPattern3 (t * testing.T ) {
155
- setting .AppURL = AppURL
156
- setting .AppSubURL = AppSubURL
154
+ setting .AppURL = TestAppURL
157
155
158
156
// alphanumeric: render inputs without valid mentions
159
157
test := func (s string ) {
@@ -178,8 +176,7 @@ func TestRender_IssueIndexPattern3(t *testing.T) {
178
176
}
179
177
180
178
func TestRender_IssueIndexPattern4 (t * testing.T ) {
181
- setting .AppURL = AppURL
182
- setting .AppSubURL = AppSubURL
179
+ setting .AppURL = TestAppURL
183
180
184
181
// alphanumeric: render inputs with valid mentions
185
182
test := func (s , expectedFmt string , names ... string ) {
@@ -197,7 +194,7 @@ func TestRender_IssueIndexPattern4(t *testing.T) {
197
194
198
195
func testRenderIssueIndexPattern (t * testing.T , input , expected string , ctx * RenderContext ) {
199
196
if ctx .URLPrefix == "" {
200
- ctx .URLPrefix = AppSubURL
197
+ ctx .URLPrefix = TestAppURL
201
198
}
202
199
203
200
var buf strings.Builder
@@ -207,21 +204,20 @@ func testRenderIssueIndexPattern(t *testing.T, input, expected string, ctx *Rend
207
204
}
208
205
209
206
func TestRender_AutoLink (t * testing.T ) {
210
- setting .AppURL = AppURL
211
- setting .AppSubURL = AppSubURL
207
+ setting .AppURL = TestAppURL
212
208
213
209
test := func (input , expected string ) {
214
210
var buffer strings.Builder
215
211
err := PostProcess (& RenderContext {
216
- URLPrefix : setting . AppSubURL ,
212
+ URLPrefix : TestRepoURL ,
217
213
Metas : localMetas ,
218
214
}, strings .NewReader (input ), & buffer )
219
215
assert .Equal (t , err , nil )
220
216
assert .Equal (t , strings .TrimSpace (expected ), strings .TrimSpace (buffer .String ()))
221
217
222
218
buffer .Reset ()
223
219
err = PostProcess (& RenderContext {
224
- URLPrefix : setting . AppSubURL ,
220
+ URLPrefix : TestRepoURL ,
225
221
Metas : localMetas ,
226
222
IsWiki : true ,
227
223
}, strings .NewReader (input ), & buffer )
@@ -230,11 +226,11 @@ func TestRender_AutoLink(t *testing.T) {
230
226
}
231
227
232
228
// render valid issue URLs
233
- test (util .URLJoin (setting . AppSubURL , "issues" , "3333" ),
234
- numericIssueLink (util .URLJoin (setting . AppSubURL , "issues" ), "ref-issue" , 3333 , "#" ))
229
+ test (util .URLJoin (TestRepoURL , "issues" , "3333" ),
230
+ numericIssueLink (util .URLJoin (TestRepoURL , "issues" ), "ref-issue" , 3333 , "#" ))
235
231
236
232
// render valid commit URLs
237
- tmp := util .URLJoin (AppSubURL , "commit" , "d8a994ef243349f321568f9e36d5c3f444b99cae" )
233
+ tmp := util .URLJoin (TestRepoURL , "commit" , "d8a994ef243349f321568f9e36d5c3f444b99cae" )
238
234
test (tmp , "<a href=\" " + tmp + "\" class=\" commit\" ><code class=\" nohighlight\" >d8a994ef24</code></a>" )
239
235
tmp += "#diff-2"
240
236
test (tmp , "<a href=\" " + tmp + "\" class=\" commit\" ><code class=\" nohighlight\" >d8a994ef24 (diff-2)</code></a>" )
@@ -245,13 +241,12 @@ func TestRender_AutoLink(t *testing.T) {
245
241
}
246
242
247
243
func TestRender_FullIssueURLs (t * testing.T ) {
248
- setting .AppURL = AppURL
249
- setting .AppSubURL = AppSubURL
244
+ setting .AppURL = TestAppURL
250
245
251
246
test := func (input , expected string ) {
252
247
var result strings.Builder
253
248
err := postProcess (& RenderContext {
254
- URLPrefix : AppSubURL ,
249
+ URLPrefix : TestRepoURL ,
255
250
Metas : localMetas ,
256
251
}, []processor {fullIssuePatternProcessor }, strings .NewReader (input ), & result )
257
252
assert .NoError (t , err )
0 commit comments