aboutsummaryrefslogtreecommitdiffstats
path: root/models/issues/pull_test.go
diff options
context:
space:
mode:
authorVladimir Buyanov <81759784+cl-bvl@users.noreply.github.com>2023-06-08 11:56:05 +0300
committerGitHub <noreply@github.com>2023-06-08 16:56:05 +0800
commit3bdd48016f659c440d6e8bb57386fab7ad7b357b (patch)
tree7cf65016a18ce0e3d0e96e29838d40008f4306fe /models/issues/pull_test.go
parentb5a2bb9ab347fb5aaa6c6ca95dfd1b31751f1fba (diff)
downloadgitea-3bdd48016f659c440d6e8bb57386fab7ad7b357b.tar.gz
gitea-3bdd48016f659c440d6e8bb57386fab7ad7b357b.zip
Add codeowners feature (#24910)
Hello. This PR adds a github like configuration for the CODEOWNERS file. Resolves: #10161
Diffstat (limited to 'models/issues/pull_test.go')
-rw-r--r--models/issues/pull_test.go22
1 files changed, 22 insertions, 0 deletions
diff --git a/models/issues/pull_test.go b/models/issues/pull_test.go
index 7a183ac312..1eb106047c 100644
--- a/models/issues/pull_test.go
+++ b/models/issues/pull_test.go
@@ -303,3 +303,25 @@ func TestDeleteOrphanedObjects(t *testing.T) {
assert.NoError(t, err)
assert.EqualValues(t, countBefore, countAfter)
}
+
+func TestParseCodeOwnersLine(t *testing.T) {
+ type CodeOwnerTest struct {
+ Line string
+ Tokens []string
+ }
+
+ given := []CodeOwnerTest{
+ {Line: "", Tokens: nil},
+ {Line: "# comment", Tokens: []string{}},
+ {Line: "!.* @user1 @org1/team1", Tokens: []string{"!.*", "@user1", "@org1/team1"}},
+ {Line: `.*\\.js @user2 #comment`, Tokens: []string{`.*\.js`, "@user2"}},
+ {Line: `docs/(aws|google|azure)/[^/]*\\.(md|txt) @user3 @org2/team2`, Tokens: []string{`docs/(aws|google|azure)/[^/]*\.(md|txt)`, "@user3", "@org2/team2"}},
+ {Line: `\#path @user3`, Tokens: []string{`#path`, "@user3"}},
+ {Line: `path\ with\ spaces/ @user3`, Tokens: []string{`path with spaces/`, "@user3"}},
+ }
+
+ for _, g := range given {
+ tokens := issues_model.TokenizeCodeOwnersLine(g.Line)
+ assert.Equal(t, g.Tokens, tokens, "Codeowners tokenizer failed")
+ }
+}