diff options
author | guillep2k <18600385+guillep2k@users.noreply.github.com> | 2019-10-13 19:29:10 -0300 |
---|---|---|
committer | zeripath <art27@cantab.net> | 2019-10-13 23:29:10 +0100 |
commit | 15809d81f7d36759f289b941352a9754611c5dba (patch) | |
tree | f9362e535fb67aa59859b535ec6c58ccf5a139bf /models/action_test.go | |
parent | 6e3f51098b29cd5c61d62732a42a7554cbc8cc2f (diff) | |
download | gitea-15809d81f7d36759f289b941352a9754611c5dba.tar.gz gitea-15809d81f7d36759f289b941352a9754611c5dba.zip |
Rewrite reference processing code in preparation for opening/closing from comment references (#8261)
* Add a markdown stripper for mentions and xrefs
* Improve comments
* Small code simplification
* Move reference code to modules/references
* Fix typo
* Make MarkdownStripper return [][]byte
* Implement preliminary keywords parsing
* Add FIXME comment
* Fix comment
* make fmt
* Fix permissions check
* Fix text assumptions
* Fix imports
* Fix lint, fmt
* Fix unused import
* Add missing export comment
* Bypass revive on implemented interface
* Move mdstripper into its own package
* Support alphanumeric patterns
* Refactor FindAllMentions
* Move mentions test to references
* Parse mentions from reference package
* Refactor code to implement renderizable references
* Fix typo
* Move patterns and tests to the references package
* Fix nil reference
* Preliminary rendering attempt of closing keywords
* Normalize names, comments, general tidy-up
* Add CSS style for action keywords
* Fix permission for admin and owner
* Fix golangci-lint
* Fix golangci-lint
Diffstat (limited to 'models/action_test.go')
-rw-r--r-- | models/action_test.go | 53 |
1 files changed, 1 insertions, 52 deletions
diff --git a/models/action_test.go b/models/action_test.go index c90538ebe6..df41556850 100644 --- a/models/action_test.go +++ b/models/action_test.go @@ -1,7 +1,6 @@ package models import ( - "fmt" "path" "strings" "testing" @@ -181,56 +180,6 @@ func TestPushCommits_AvatarLink(t *testing.T) { pushCommits.AvatarLink("nonexistent@example.com")) } -func TestRegExp_issueReferenceKeywordsPat(t *testing.T) { - trueTestCases := []string{ - "#2", - "[#2]", - "please see go-gitea/gitea#5", - "#2:", - } - falseTestCases := []string{ - "kb#2", - "#2xy", - } - - for _, testCase := range trueTestCases { - assert.True(t, issueReferenceKeywordsPat.MatchString(testCase)) - } - for _, testCase := range falseTestCases { - assert.False(t, issueReferenceKeywordsPat.MatchString(testCase)) - } -} - -func Test_getIssueFromRef(t *testing.T) { - assert.NoError(t, PrepareTestDatabase()) - repo := AssertExistsAndLoadBean(t, &Repository{ID: 1}).(*Repository) - for _, test := range []struct { - Ref string - ExpectedIssueID int64 - }{ - {"#2", 2}, - {"reopen #2", 2}, - {"user2/repo2#1", 4}, - {"fixes user2/repo2#1", 4}, - {"fixes: user2/repo2#1", 4}, - } { - issue, err := getIssueFromRef(repo, test.Ref) - assert.NoError(t, err) - if assert.NotNil(t, issue) { - assert.EqualValues(t, test.ExpectedIssueID, issue.ID) - } - } - - for _, badRef := range []string{ - "doesnotexist/doesnotexist#1", - fmt.Sprintf("#%d", NonexistentID), - } { - issue, err := getIssueFromRef(repo, badRef) - assert.NoError(t, err) - assert.Nil(t, issue) - } -} - func TestUpdateIssuesCommit(t *testing.T) { assert.NoError(t, PrepareTestDatabase()) pushCommits := []*PushCommit{ @@ -431,7 +380,7 @@ func TestUpdateIssuesCommit_AnotherRepoNoPermission(t *testing.T) { AssertNotExistsBean(t, commentBean) AssertNotExistsBean(t, issueBean, "is_closed=1") assert.NoError(t, UpdateIssuesCommit(user, repo, pushCommits, repo.DefaultBranch)) - AssertExistsAndLoadBean(t, commentBean) + AssertNotExistsBean(t, commentBean) AssertNotExistsBean(t, issueBean, "is_closed=1") CheckConsistencyFor(t, &Action{}) } |