@@ -65,77 +65,83 @@ func TestRegisterCheckerAgain(t *testing.T) {
6565}
6666
6767func TestSeverityLevelLabels (t * testing.T ) {
68- if codeowners .Error .String () != "Error" {
68+ if codeowners .Error .Name () != "Error" {
6969 t .Errorf ("codeowners.Error.String() should evaluate to 'Error'" )
7070 }
71- if codeowners .Warning .String () != "Warning" {
71+ if codeowners .Warning .Name () != "Warning" {
7272 t .Errorf ("codeowners.Warning.String() should evaluate to 'Warning'" )
7373 }
7474}
7575
76- func TestPositionString (t * testing.T ) {
76+ func TestPositionFormat (t * testing.T ) {
7777 testCases := []struct {
7878 input codeowners.Position
7979 want string
8080 }{
8181 {
8282 input : codeowners.Position {
83+ FilePath : "CODEOWNERS" ,
8384 StartLine : 1 ,
8485 StartColumn : 1 ,
8586 EndLine : 2 ,
8687 EndColumn : 2 ,
8788 },
88- want : "1:1-2:2" ,
89+ want : "CODEOWNERS 1:1-2:2" ,
8990 },
9091 {
9192 input : codeowners.Position {
93+ FilePath : "CODEOWNERS" ,
9294 StartLine : 1 ,
9395 StartColumn : 1 ,
9496 EndLine : 1 ,
9597 EndColumn : 2 ,
9698 },
97- want : "1:1-2" ,
99+ want : "CODEOWNERS 1:1-2" ,
98100 },
99101 {
100102 input : codeowners.Position {
103+ FilePath : "CODEOWNERS" ,
101104 StartLine : 1 ,
102105 StartColumn : 1 ,
103106 EndLine : 1 ,
104107 EndColumn : 1 ,
105108 },
106- want : "1:1" ,
109+ want : "CODEOWNERS 1:1" ,
107110 },
108111 {
109112 input : codeowners.Position {
113+ FilePath : "CODEOWNERS" ,
110114 StartLine : 1 ,
111115 StartColumn : 0 ,
112116 EndLine : 1 ,
113117 EndColumn : 0 ,
114118 },
115- want : "1" ,
119+ want : "CODEOWNERS 1" ,
116120 },
117121 {
118122 input : codeowners.Position {
123+ FilePath : "CODEOWNERS" ,
119124 StartLine : 1 ,
120125 StartColumn : 0 ,
121126 EndLine : 0 ,
122127 EndColumn : 0 ,
123128 },
124- want : "1" ,
129+ want : "CODEOWNERS 1" ,
125130 },
126131 {
127132 input : codeowners.Position {
133+ FilePath : "CODEOWNERS" ,
128134 StartLine : 0 ,
129135 StartColumn : 0 ,
130136 EndLine : 0 ,
131137 EndColumn : 0 ,
132138 },
133- want : "0" ,
139+ want : "CODEOWNERS 0" ,
134140 },
135141 }
136142
137143 for _ , testCase := range testCases {
138- got := testCase .input .String ()
144+ got := testCase .input .Format ()
139145 if got != testCase .want {
140146 t .Errorf ("Input: %v, Want: %v, Got: %v" , testCase .input , testCase .want , got )
141147 }
@@ -200,6 +206,9 @@ func TestNoCodeownersCheck(t *testing.T) {
200206 input := "./test/data"
201207 want := []codeowners.CheckResult {
202208 {
209+ Position : codeowners.Position {
210+ FilePath : "CODEOWNERS" ,
211+ },
203212 Message : "No CODEOWNERS file found" ,
204213 Severity : codeowners .Error ,
205214 CheckName : "NoCodeowners" ,
@@ -222,6 +231,9 @@ func TestMultipleCodeownersCheck(t *testing.T) {
222231 input := "./test/data/multiple_codeowners"
223232 want := []codeowners.CheckResult {
224233 {
234+ Position : codeowners.Position {
235+ FilePath : "CODEOWNERS" ,
236+ },
225237 Message : "Multiple CODEOWNERS files found (CODEOWNERS, docs/CODEOWNERS)" ,
226238 Severity : codeowners .Warning ,
227239 CheckName : "MultipleCodeowners" ,
@@ -249,8 +261,8 @@ func ExampleCheck() {
249261 panic (err )
250262 }
251263 for _ , check := range checks {
252- fmt .Printf ("%s ::%s:: %s [%s]\n " , check .Position , check .Severity , check .Message , check .CheckName )
264+ fmt .Printf ("%s ::%s:: %s [%s]\n " , check .Position . Format () , check .Severity . Name () , check .Message , check .CheckName )
253265 }
254266 //Output:
255- //0 ::Error:: No CODEOWNERS file found [NoCodeowners]
267+ //CODEOWNERS 0 ::Error:: No CODEOWNERS file found [NoCodeowners]
256268}
0 commit comments