From 780875d6452cf80c7c041bc8fff0f046a1995b2b Mon Sep 17 00:00:00 2001 From: vilmibm Date: Fri, 15 May 2020 16:47:11 -0500 Subject: [PATCH] fix tests --- command/gist_test.go | 2 +- command/root.go | 2 +- command/testing.go | 3 +++ 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/command/gist_test.go b/command/gist_test.go index eeaac4701..35eedfed1 100644 --- a/command/gist_test.go +++ b/command/gist_test.go @@ -23,7 +23,7 @@ func TestGistCreate(t *testing.T) { } `)) - output, err := RunCommand(gistCreateCmd, `gist create -f "../test/fixtures/gistCreate.json" -d "Gist description" -p=false`) + output, err := RunCommand(`gist create -f "../test/fixtures/gistCreate.json" -d "Gist description" -p=false`) eq(t, err, nil) bodyBytes, _ := ioutil.ReadAll(http.Requests[0].Body) diff --git a/command/root.go b/command/root.go index 0bdfaeca5..1662665b7 100644 --- a/command/root.go +++ b/command/root.go @@ -184,7 +184,7 @@ var apiClientForContext = func(ctx context.Context) (*api.Client, error) { return api.NewClient(opts...), nil } -func ensureScopes(ctx context.Context, client *api.Client, wantedScopes ...string) (*api.Client, error) { +var ensureScopes = func(ctx context.Context, client *api.Client, wantedScopes ...string) (*api.Client, error) { hasScopes, appID, err := client.HasScopes(wantedScopes...) if err != nil { return client, err diff --git a/command/testing.go b/command/testing.go index 784488fd8..5612f58ea 100644 --- a/command/testing.go +++ b/command/testing.go @@ -96,6 +96,9 @@ func initBlankContext(cfg, repo, branch string) { func initFakeHTTP() *httpmock.Registry { http := &httpmock.Registry{} + ensureScopes = func(ctx context.Context, client *api.Client, wantedScopes ...string) (*api.Client, error) { + return client, nil + } apiClientForContext = func(context.Context) (*api.Client, error) { return api.NewClient(api.ReplaceTripper(http)), nil }