diff options
author | guillep2k <18600385+guillep2k@users.noreply.github.com> | 2020-02-01 15:01:30 -0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-02-01 18:01:30 +0000 |
commit | 131baa26bed62b933a244e6972595201ee41d7e2 (patch) | |
tree | 1c03e6b99cad2c650c4042a7aa8fd6f15b69595a /modules/references/references_test.go | |
parent | f8f6adc2a6ea3fe07fdbc80f2b3cafbb893e2a1f (diff) | |
download | gitea-131baa26bed62b933a244e6972595201ee41d7e2.tar.gz gitea-131baa26bed62b933a244e6972595201ee41d7e2.zip |
Accept punctuation after simple+cross repository issue references (#10091)
* Support references ending in , . and ;
* Accept :;, in simple refs; fix 2+ consecutive refs
* Include cross-repository references
* Add ?!, fix spacing problem
Diffstat (limited to 'modules/references/references_test.go')
-rw-r--r-- | modules/references/references_test.go | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/modules/references/references_test.go b/modules/references/references_test.go index bcb2c4384f..48589c1637 100644 --- a/modules/references/references_test.go +++ b/modules/references/references_test.go @@ -136,6 +136,39 @@ func TestFindAllIssueReferences(t *testing.T) { }, }, { + "For [!123] yes", + []testResult{ + {123, "", "", "123", true, XRefActionNone, &RefSpan{Start: 5, End: 9}, nil}, + }, + }, + { + "For (#345) yes", + []testResult{ + {345, "", "", "345", false, XRefActionNone, &RefSpan{Start: 5, End: 9}, nil}, + }, + }, + { + "For #22,#23 no, neither #28:#29 or !30!31#32;33 should", + []testResult{}, + }, + { + "For #24, and #25. yes; also #26; #27? #28! and #29: should", + []testResult{ + {24, "", "", "24", false, XRefActionNone, &RefSpan{Start: 4, End: 7}, nil}, + {25, "", "", "25", false, XRefActionNone, &RefSpan{Start: 13, End: 16}, nil}, + {26, "", "", "26", false, XRefActionNone, &RefSpan{Start: 28, End: 31}, nil}, + {27, "", "", "27", false, XRefActionNone, &RefSpan{Start: 33, End: 36}, nil}, + {28, "", "", "28", false, XRefActionNone, &RefSpan{Start: 38, End: 41}, nil}, + {29, "", "", "29", false, XRefActionNone, &RefSpan{Start: 47, End: 50}, nil}, + }, + }, + { + "This user3/repo4#200, yes.", + []testResult{ + {200, "user3", "repo4", "200", false, XRefActionNone, &RefSpan{Start: 5, End: 20}, nil}, + }, + }, + { "Which abc. #9434 same as above", []testResult{ {9434, "", "", "9434", false, XRefActionNone, &RefSpan{Start: 11, End: 16}, nil}, @@ -217,6 +250,16 @@ func testFixtures(t *testing.T, fixtures []testFixture, context string) { setting.AppURL = prevURL } +func TestFindAllMentions(t *testing.T) { + res := FindAllMentionsBytes([]byte("@tasha, @mike; @lucy: @john")) + assert.EqualValues(t, []RefSpan{ + {Start: 0, End: 6}, + {Start: 8, End: 13}, + {Start: 15, End: 20}, + {Start: 22, End: 27}, + }, res) +} + func TestRegExp_mentionPattern(t *testing.T) { trueTestCases := []struct { pat string |