Skip to content

Commit

Permalink
Fix up tests
Browse files Browse the repository at this point in the history
  • Loading branch information
samcoe committed Mar 20, 2023
1 parent 842342a commit 1ed0150
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 10 deletions.
8 changes: 4 additions & 4 deletions example_gh_test.go
Expand Up @@ -103,7 +103,7 @@ func ExampleRESTClient_pagination() {
}
return "", false
}
client, err := gh.RESTClient(nil)
client, err := api.DefaultRESTClient()
if err != nil {
log.Fatal(err)
}
Expand Down Expand Up @@ -195,8 +195,8 @@ func ExampleGQLClient() {
}

// Add a star to the cli/go-gh repository using the GQL API.
func ExampleGQLClient_mutate_simple() {
client, err := gh.GQLClient(nil)
func ExampleGQLClient_mutate() {
client, err := api.DefaultGQLClient()
if err != nil {
log.Fatal(err)
}
Expand Down Expand Up @@ -231,7 +231,7 @@ func ExampleGQLClient_mutate_simple() {

// Query releases from cli/cli repository using GQL API with paginated results.
func ExampleGQLClient_pagination() {
client, err := gh.GQLClient(nil)
client, err := api.DefaultGQLClient()
if err != nil {
log.Fatal(err)
}
Expand Down
18 changes: 12 additions & 6 deletions pkg/api/cache_test.go
Expand Up @@ -31,13 +31,17 @@ func TestCacheResponse(t *testing.T) {

cacheDir := filepath.Join(t.TempDir(), "gh-cli-cache")

httpClient, _ := NewHTTPClient(
httpClient, err := NewHTTPClient(
ClientOptions{
Host: "github.com",
AuthToken: "token",
Transport: fakeHTTP,
EnableCache: true,
CacheDir: cacheDir,
LogIgnoreEnv: true,
})
},
)
assert.NoError(t, err)

do := func(method, url string, body io.Reader) (string, error) {
req, err := http.NewRequest(method, url, body)
Expand All @@ -57,7 +61,6 @@ func TestCacheResponse(t *testing.T) {
}

var res string
var err error

res, err = do("GET", "http://example.com/path", nil)
assert.NoError(t, err)
Expand Down Expand Up @@ -112,13 +115,17 @@ func TestCacheResponseRequestCacheOptions(t *testing.T) {

cacheDir := filepath.Join(t.TempDir(), "gh-cli-cache")

httpClient, _ := NewHTTPClient(
httpClient, err := NewHTTPClient(
ClientOptions{
Host: "github.com",
AuthToken: "token",
Transport: fakeHTTP,
EnableCache: false,
CacheDir: cacheDir,
LogIgnoreEnv: true,
})
},
)
assert.NoError(t, err)

do := func(method, url string, body io.Reader) (string, error) {
req, err := http.NewRequest(method, url, body)
Expand All @@ -140,7 +147,6 @@ func TestCacheResponseRequestCacheOptions(t *testing.T) {
}

var res string
var err error

res, err = do("GET", "http://example.com/path", nil)
assert.NoError(t, err)
Expand Down

0 comments on commit 1ed0150

Please sign in to comment.