@@ -35,6 +35,7 @@ func TestAccessCheck(t *testing.T) {
3535 validator := checker .NewValidator (codeowners.ValidatorOptions {
3636 Directory : "." ,
3737 CodeownersFileLocation : "CODEOWNERS" ,
38+ GithubToken : "token" ,
3839 })
3940 got := validator .ValidateLine (input .lineNo , input .line )
4041 if ! reflect .DeepEqual (got , want ) {
@@ -69,6 +70,7 @@ func TestAccessCheckError(t *testing.T) {
6970 validator := checker .NewValidator (codeowners.ValidatorOptions {
7071 Directory : "." ,
7172 CodeownersFileLocation : "CODEOWNERS" ,
73+ GithubToken : "token" ,
7274 })
7375 got := validator .ValidateLine (input .lineNo , input .line )
7476 if ! reflect .DeepEqual (got , want ) {
@@ -88,6 +90,7 @@ func TestAccessCheckPass(t *testing.T) {
8890 validator := checker .NewValidator (codeowners.ValidatorOptions {
8991 Directory : "." ,
9092 CodeownersFileLocation : "CODEOWNERS" ,
93+ GithubToken : "token" ,
9194 })
9295 got := validator .ValidateLine (input .lineNo , input .line )
9396 if got != nil {
@@ -107,6 +110,7 @@ func TestAccessCheckPassInvalidOwners(t *testing.T) {
107110 validator := checker .NewValidator (codeowners.ValidatorOptions {
108111 Directory : "." ,
109112 CodeownersFileLocation : "CODEOWNERS" ,
113+ GithubToken : "token" ,
110114 })
111115 got := validator .ValidateLine (input .lineNo , input .line )
112116 if got != nil {
@@ -126,6 +130,26 @@ func TestAccessCheckPassNoOwners(t *testing.T) {
126130 validator := checker .NewValidator (codeowners.ValidatorOptions {
127131 Directory : "." ,
128132 CodeownersFileLocation : "CODEOWNERS" ,
133+ GithubToken : "token" ,
134+ })
135+ got := validator .ValidateLine (input .lineNo , input .line )
136+ if got != nil {
137+ t .Errorf ("Input: %v, Want: %v, Got: %v" , input , nil , got )
138+ }
139+ }
140+
141+ func TestAccessCheckNoTokenPass (t * testing.T ) {
142+ input := struct {
143+ lineNo int
144+ line string
145+ }{
146+ lineNo : 1 ,
147+ line : "filepattern @ownerWithAccess" ,
148+ }
149+ checker := checkers.Access {}
150+ validator := checker .NewValidator (codeowners.ValidatorOptions {
151+ Directory : "bad" ,
152+ CodeownersFileLocation : "bad" ,
129153 })
130154 got := validator .ValidateLine (input .lineNo , input .line )
131155 if got != nil {
@@ -159,6 +183,7 @@ func TestAccessCheckInvalidDir(t *testing.T) {
159183 validator := checker .NewValidator (codeowners.ValidatorOptions {
160184 Directory : "bad" ,
161185 CodeownersFileLocation : "bad" ,
186+ GithubToken : "token" ,
162187 })
163188 got := validator .ValidateLine (input .lineNo , input .line )
164189 if ! reflect .DeepEqual (got , want ) {
@@ -192,6 +217,7 @@ func TestAccessCheckNoCollaborator(t *testing.T) {
192217 validator := checker .NewValidator (codeowners.ValidatorOptions {
193218 Directory : "." ,
194219 CodeownersFileLocation : "CODEOWNERS" ,
220+ GithubToken : "token" ,
195221 })
196222 got := validator .ValidateLine (input .lineNo , input .line )
197223 if ! reflect .DeepEqual (got , want ) {
@@ -225,6 +251,7 @@ func TestAccessCheckIsCollaboratorError(t *testing.T) {
225251 validator := checker .NewValidator (codeowners.ValidatorOptions {
226252 Directory : "." ,
227253 CodeownersFileLocation : "CODEOWNERS" ,
254+ GithubToken : "token" ,
228255 })
229256 got := validator .ValidateLine (input .lineNo , input .line )
230257 if ! reflect .DeepEqual (got , want ) {
@@ -244,6 +271,7 @@ func TestAccessCheckTeamPass(t *testing.T) {
244271 validator := checker .NewValidator (codeowners.ValidatorOptions {
245272 Directory : "." ,
246273 CodeownersFileLocation : "CODEOWNERS" ,
274+ GithubToken : "token" ,
247275 })
248276 got := validator .ValidateLine (input .lineNo , input .line )
249277 if got != nil {
@@ -257,7 +285,7 @@ func TestAccessCheckTeamDeny(t *testing.T) {
257285 line string
258286 }{
259287 lineNo : 1 ,
260- line : "filepattern @org/team " ,
288+ line : "filepattern @org/denyTeam " ,
261289 }
262290 want := []codeowners.CheckResult {
263291 {
@@ -266,9 +294,9 @@ func TestAccessCheckTeamDeny(t *testing.T) {
266294 StartLine : 1 ,
267295 StartColumn : 13 ,
268296 EndLine : 1 ,
269- EndColumn : 22 ,
297+ EndColumn : 26 ,
270298 },
271- Message : "Owner '@org/team ' has no write access" ,
299+ Message : "Owner '@org/denyTeam ' has no write access" ,
272300 Severity : codeowners .Error ,
273301 CheckName : "Access" ,
274302 },
@@ -277,6 +305,7 @@ func TestAccessCheckTeamDeny(t *testing.T) {
277305 validator := checker .NewValidator (codeowners.ValidatorOptions {
278306 Directory : "." ,
279307 CodeownersFileLocation : "CODEOWNERS" ,
308+ GithubToken : "token" ,
280309 })
281310 got := validator .ValidateLine (input .lineNo , input .line )
282311 if ! reflect .DeepEqual (got , want ) {
@@ -296,6 +325,7 @@ func TestAccessCheckEmailPass(t *testing.T) {
296325 validator := checker .NewValidator (codeowners.ValidatorOptions {
297326 Directory : "." ,
298327 CodeownersFileLocation : "CODEOWNERS" ,
328+ GithubToken : "token" ,
299329 })
300330 got := validator .ValidateLine (input .lineNo , input .line )
301331 if got != nil {
@@ -328,6 +358,7 @@ func TestAccessCheckEmailDeny(t *testing.T) {
328358 validator := checker .NewValidator (codeowners.ValidatorOptions {
329359 Directory : "." ,
330360 CodeownersFileLocation : "CODEOWNERS" ,
361+ GithubToken : "token" ,
331362 })
332363 got := validator .ValidateLine (input .lineNo , input .line )
333364 if ! reflect .DeepEqual (got , want ) {
@@ -342,11 +373,11 @@ func TestAccessCheckDenyMemo(t *testing.T) {
342373 }{
343374 {
344375 lineNo : 1 ,
345- line : "filepattern @org/team " ,
376+ line : "filepattern @org/denyTeam " ,
346377 },
347378 {
348379 lineNo : 2 ,
349- line : "filepattern2 @org/team " ,
380+ line : "filepattern2 @org/denyTeam " ,
350381 },
351382 }
352383 want := []codeowners.CheckResult {
@@ -356,9 +387,9 @@ func TestAccessCheckDenyMemo(t *testing.T) {
356387 StartLine : 1 ,
357388 StartColumn : 13 ,
358389 EndLine : 1 ,
359- EndColumn : 22 ,
390+ EndColumn : 26 ,
360391 },
361- Message : "Owner '@org/team ' has no write access" ,
392+ Message : "Owner '@org/denyTeam ' has no write access" ,
362393 Severity : codeowners .Error ,
363394 CheckName : "Access" ,
364395 },
@@ -368,9 +399,9 @@ func TestAccessCheckDenyMemo(t *testing.T) {
368399 StartLine : 2 ,
369400 StartColumn : 14 ,
370401 EndLine : 2 ,
371- EndColumn : 23 ,
402+ EndColumn : 27 ,
372403 },
373- Message : "Owner '@org/team ' has no write access" ,
404+ Message : "Owner '@org/denyTeam ' has no write access" ,
374405 Severity : codeowners .Error ,
375406 CheckName : "Access" ,
376407 },
@@ -379,6 +410,7 @@ func TestAccessCheckDenyMemo(t *testing.T) {
379410 validator := checker .NewValidator (codeowners.ValidatorOptions {
380411 Directory : "." ,
381412 CodeownersFileLocation : "CODEOWNERS" ,
413+ GithubToken : "token" ,
382414 })
383415 got := []codeowners.CheckResult {}
384416 for _ , inputLine := range input {
0 commit comments