@@ -14,7 +14,7 @@ import (
14
14
"github.com/google/go-cmp/cmp"
15
15
)
16
16
17
- func TestRepositoriesService_GetCodeownersErrors (t * testing.T ) {
17
+ func TestRepositoriesService_GetCodeownersErrors_noRef (t * testing.T ) {
18
18
client , mux , _ , teardown := setup ()
19
19
defer teardown ()
20
20
@@ -75,6 +75,68 @@ func TestRepositoriesService_GetCodeownersErrors(t *testing.T) {
75
75
})
76
76
}
77
77
78
+ func TestRepositoriesService_GetCodeownersErrors_specificRef (t * testing.T ) {
79
+ client , mux , _ , teardown := setup ()
80
+ defer teardown ()
81
+
82
+ mux .HandleFunc ("/repos/o/r/codeowners/errors" , func (w http.ResponseWriter , r * http.Request ) {
83
+ testMethod (t , r , "GET" )
84
+ testHeader (t , r , "Accept" , mediaTypeV3 )
85
+ fmt .Fprint (w , `{
86
+ "errors": [
87
+ {
88
+ "line": 1,
89
+ "column": 1,
90
+ "kind": "Invalid pattern",
91
+ "source": "***/*.rb @monalisa",
92
+ "suggestion": "Did you mean **/*.rb?",
93
+ "message": "Invalid pattern on line 3: Did you mean **/*.rb?\n\n ***/*.rb @monalisa\n ^",
94
+ "path": ".github/CODEOWNERS"
95
+ }
96
+ ]
97
+ }
98
+ ` )
99
+ })
100
+
101
+ opts := & GetCodeownersErrorsOptions {Ref : "mybranch" }
102
+ ctx := context .Background ()
103
+ codeownersErrors , _ , err := client .Repositories .GetCodeownersErrors (ctx , "o" , "r" , opts )
104
+ if err != nil {
105
+ t .Errorf ("Repositories.GetCodeownersErrors returned error: %v" , err )
106
+ }
107
+
108
+ want := & CodeownersErrors {
109
+ Errors : []* CodeownersError {
110
+ {
111
+ Line : 1 ,
112
+ Column : 1 ,
113
+ Kind : "Invalid pattern" ,
114
+ Source : "***/*.rb @monalisa" ,
115
+ Suggestion : String ("Did you mean **/*.rb?" ),
116
+ Message : "Invalid pattern on line 3: Did you mean **/*.rb?\n \n ***/*.rb @monalisa\n ^" ,
117
+ Path : ".github/CODEOWNERS" ,
118
+ },
119
+ },
120
+ }
121
+ if ! cmp .Equal (codeownersErrors , want ) {
122
+ t .Errorf ("Repositories.GetCodeownersErrors returned %+v, want %+v" , codeownersErrors , want )
123
+ }
124
+
125
+ const methodName = "GetCodeownersErrors"
126
+ testBadOptions (t , methodName , func () (err error ) {
127
+ _ , _ , err = client .Repositories .GetCodeownersErrors (ctx , "\n " , "\n " , opts )
128
+ return err
129
+ })
130
+
131
+ testNewRequestAndDoFailure (t , methodName , client , func () (* Response , error ) {
132
+ got , resp , err := client .Repositories .GetCodeownersErrors (ctx , "o" , "r" , opts )
133
+ if got != nil {
134
+ t .Errorf ("testNewRequestAndDoFailure %v = %#v, want nil" , methodName , got )
135
+ }
136
+ return resp , err
137
+ })
138
+ }
139
+
78
140
func TestCodeownersErrors_Marshal (t * testing.T ) {
79
141
testJSONMarshal (t , & CodeownersErrors {}, "{}" )
80
142
0 commit comments