Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
omryMen committed Feb 13, 2024
1 parent 2adcca5 commit 759e131
Showing 1 changed file with 20 additions and 20 deletions.
40 changes: 20 additions & 20 deletions src/codeowners/codeowners_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ docs/** @org/docteam @joe`
sample3 = `baz/* @baz @qux`
sample4 = `[test]
* @everyone
[test2][2]
[test2]
*/foo @everyoneelse`

// based on https://help.github.com/en/github/creating-cloning-and-archiving-repositories/about-code-owners#codeowners-syntax
Expand Down Expand Up @@ -88,9 +88,9 @@ func TestParseCodeowners(t *testing.T) {
r := bytes.NewBufferString(sample)
c := parseCodeowners(r)
expected := []Codeowner{
co("*", []string{"@everyone"}),
co("foobar/", []string{"[email protected]"}),
co("docs/**", []string{"@org/docteam", "@joe"}),
co("*", []string{"@everyone"}, ""),
co("foobar/", []string{"[email protected]"}, ""),
co("docs/**", []string{"@org/docteam", "@joe"}, ""),
}
assert.Equal(t, expected, c)
}
Expand All @@ -100,8 +100,8 @@ func TestParseCodeownersSections(t *testing.T) {
r := bytes.NewBufferString(sample4)
c := parseCodeowners(r)
expected := []Codeowner{
co("*", []string{"@everyone"}),
co("*/foo", []string{"@everyoneelse"}),
co("*", []string{"@everyone"}, "test"),
co("*/foo", []string{"@everyoneelse"}, "test2"),
}
assert.Equal(t, expected, c)
}
Expand Down Expand Up @@ -153,8 +153,8 @@ func TestFindCodeownersFile(t *testing.T) {
assert.Nil(t, r)
}

func co(pattern string, owners []string) Codeowner {
c := NewCodeowner(pattern, owners, "")
func co(pattern string, owners []string, section string) Codeowner {
c := NewCodeowner(pattern, owners, section)
return c
}

Expand Down Expand Up @@ -215,20 +215,20 @@ func TestOwners(t *testing.T) {
path string
expected []string
}{
{[]Codeowner{co("a/*", foo)}, "c/b", nil},
{[]Codeowner{co("**", foo)}, "a/b", foo},
{[]Codeowner{co("**", foo), co("a/b/*", bar)}, "a/b/c", bar},
{[]Codeowner{co("**", foo), co("a/b/*", bar), co("a/b/c", baz)}, "a/b/c", baz},
{[]Codeowner{co("**", foo), co("a/*/c", bar), co("a/b/*", baz)}, "a/b/c", baz},
{[]Codeowner{co("**", foo), co("a/b/*", bar), co("a/b/", baz)}, "a/b/bar", baz},
{[]Codeowner{co("**", foo), co("a/b/*", bar), co("a/b/", baz)}, "/someroot/a/b/bar", baz},
{[]Codeowner{co("a/*", foo, "")}, "c/b", nil},
{[]Codeowner{co("**", foo, "")}, "a/b", foo},
{[]Codeowner{co("**", foo, ""), co("a/b/*", bar, "")}, "a/b/c", bar},
{[]Codeowner{co("**", foo, ""), co("a/b/*", bar, ""), co("a/b/c", baz, "")}, "a/b/c", baz},
{[]Codeowner{co("**", foo, ""), co("a/*/c", bar, ""), co("a/b/*", baz, "")}, "a/b/c", baz},
{[]Codeowner{co("**", foo, ""), co("a/b/*", bar, ""), co("a/b/", baz, "")}, "a/b/bar", baz},
{[]Codeowner{co("**", foo, ""), co("a/b/*", bar, ""), co("a/b/", baz, "")}, "/someroot/a/b/bar", baz},
{[]Codeowner{
co("*", foo),
co("/a/*", bar),
co("/b/**", baz)}, "/a/aa/file", foo},
co("*", foo, ""),
co("/a/*", bar, ""),
co("/b/**", baz, "")}, "/a/aa/file", foo},
{[]Codeowner{
co("*", foo),
co("/a/**", bar)}, "/a/bb/file", bar},
co("*", foo, ""),
co("/a/**", bar, "")}, "/a/bb/file", bar},
}

for _, d := range data {
Expand Down

0 comments on commit 759e131

Please sign in to comment.