@@ -10,7 +10,6 @@ import (
1010
1111 "github.com/cli/cli/v2/pkg/httpmock"
1212 "github.com/cli/cli/v2/pkg/iostreams"
13- "github.com/cli/go-gh/v2/pkg/api"
1413 "github.com/stretchr/testify/assert"
1514)
1615
@@ -257,79 +256,3 @@ func TestHTTPHeaders(t *testing.T) {
257256 }
258257 assert .Equal (t , "" , stderr .String ())
259258}
260-
261- func TestGenerateScopeErrorForGQL (t * testing.T ) {
262- tests := []struct {
263- name string
264- gqlError * api.GraphQLError
265- wantErr bool
266- expected string
267- }{
268- {
269- name : "missing scope" ,
270- gqlError : & api.GraphQLError {
271- Errors : []api.GraphQLErrorItem {
272- {
273- Type : "INSUFFICIENT_SCOPES" ,
274- Message : "The 'addProjectV2ItemById' field requires one of the following scopes: ['project']" ,
275- },
276- },
277- },
278- wantErr : true ,
279- expected : "error: your authentication token is missing required scopes [project]\n " +
280- "To request it, run: gh auth refresh -s project" ,
281- },
282-
283- {
284- name : "ignore non-scope errors" ,
285- gqlError : & api.GraphQLError {
286- Errors : []api.GraphQLErrorItem {
287- {
288- Type : "NOT_FOUND" ,
289- Message : "Could not resolve to a Repository" ,
290- },
291- },
292- },
293- wantErr : false ,
294- },
295- }
296-
297- for _ , tt := range tests {
298- t .Run (tt .name , func (t * testing.T ) {
299- err := GenerateScopeErrorForGQL (tt .gqlError )
300- if tt .wantErr {
301- assert .NotNil (t , err )
302- assert .Equal (t , tt .expected , err .Error ())
303- } else {
304- assert .Nil (t , err )
305- }
306- })
307- }
308- }
309-
310- func TestRequiredScopesFromServerMessage (t * testing.T ) {
311- tests := []struct {
312- msg string
313- expected []string
314- }{
315- {
316- msg : "requires one of the following scopes: ['project']" ,
317- expected : []string {"project" },
318- },
319- {
320- msg : "requires one of the following scopes: ['repo', 'read:org']" ,
321- expected : []string {"repo" , "read:org" },
322- },
323- {
324- msg : "no match here" ,
325- expected : nil ,
326- },
327- }
328-
329- for _ , tt := range tests {
330- t .Run (tt .msg , func (t * testing.T ) {
331- output := requiredScopesFromServerMessage (tt .msg )
332- assert .Equal (t , tt .expected , output )
333- })
334- }
335- }
0 commit comments