-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcodeowners_test.go
59 lines (55 loc) · 1.36 KB
/
codeowners_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
package codeowners_test
import (
"reflect"
"testing"
"github.com/fmenezes/codeowners"
)
func TestParseLine(t *testing.T) {
testCases := []struct {
input string
wantPattern string
wantOwners []string
}{
{
input: "* [email protected]",
wantPattern: "*",
},
{
input: "filepattern [email protected] @owner @company/team",
wantPattern: "filepattern",
},
{
input: "file\\ with\\ spaces @owner",
wantPattern: "file\\ with\\ spaces",
wantOwners: []string{"@owner"},
},
{
input: " filepattern ",
wantPattern: "filepattern",
wantOwners: nil,
},
{
input: "filepattern @owner # comments",
wantPattern: "filepattern",
wantOwners: []string{"@owner"},
},
{
input: "",
wantPattern: "",
wantOwners: nil,
},
{
input: "# only comments on the line",
wantPattern: "",
wantOwners: nil,
},
}
for _, testCase := range testCases {
gotPattern, gotOwners := codeowners.ParseLine(testCase.input)
if gotPattern != testCase.wantPattern || !reflect.DeepEqual(gotOwners, testCase.wantOwners) {
t.Errorf("Input: %s, Want: %s, %v, Got: %s, %v", testCase.input, testCase.wantPattern, testCase.wantOwners, gotPattern, gotOwners)
}
}
}