@@ -205,37 +205,36 @@ func TestRender_IssueIndexPattern5(t *testing.T) {
205
205
setting .AppURL = TestAppURL
206
206
207
207
// regexp: render inputs without valid mentions
208
- test := func (s , expectedFmt , pattern string , names []string ) {
209
- links := make ([]interface {}, len (names ))
210
- for i , name := range names {
211
- links [i ] = externalIssueLink ("https://someurl.com/someUser/someRepo/" , "ref-issue ref-external-issue" , name )
208
+ test := func (s , expectedFmt , pattern string , ids , names []string ) {
209
+ metas := regexpMetas
210
+ metas ["regexp" ] = pattern
211
+ links := make ([]interface {}, len (ids ))
212
+ for i , id := range ids {
213
+ links [i ] = link (util .URLJoin ("https://someurl.com/someUser/someRepo/" , id ), "ref-issue ref-external-issue" , names [i ])
212
214
}
213
215
214
- metas := map [string ]string {}
215
- for k , v := range regexpMetas {
216
- metas [k ] = v
217
- }
218
- metas ["regexp" ] = pattern
219
216
expected := fmt .Sprintf (expectedFmt , links ... )
220
217
testRenderIssueIndexPattern (t , s , expected , & RenderContext {Metas : metas })
221
218
}
222
219
223
220
test ("abc ISSUE-123 def" , "abc %s def" ,
224
221
"ISSUE-(\\ d+)" ,
222
+ []string {"123" },
225
223
[]string {"ISSUE-123" },
226
224
)
227
225
228
226
test ("abc (ISSUE 123) def" , "abc %s def" ,
229
227
"\\ (ISSUE (\\ d+)\\ )" ,
228
+ []string {"123" },
230
229
[]string {"(ISSUE 123)" },
231
230
)
232
231
233
- test ("abc (ISSUE 123) def (TASK 456) ghi" , "abc %s def %s ghi" , "\\ ((?:ISSUE|TASK) (\\ d+)\\ )" ,
234
- []string {"(ISSUE 123)" , "(TASK 456)" },
232
+ test ("abc ISSUE-123 def" , "abc %s def" ,
233
+ "(ISSUE-(\\ d+))" ,
234
+ []string {"ISSUE-123" },
235
+ []string {"ISSUE-123" },
235
236
)
236
237
237
- metas := regexpMetas
238
- metas ["regexp" ] = "no matches"
239
238
testRenderIssueIndexPattern (t , "will not match" , "will not match" , & RenderContext {Metas : regexpMetas })
240
239
}
241
240
0 commit comments