Skip to content

Commit 1ed0150

Browse files
committed
Fix up tests
1 parent 842342a commit 1ed0150

File tree

2 files changed

+16
-10
lines changed

2 files changed

+16
-10
lines changed

example_gh_test.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ func ExampleRESTClient_pagination() {
103103
}
104104
return "", false
105105
}
106-
client, err := gh.RESTClient(nil)
106+
client, err := api.DefaultRESTClient()
107107
if err != nil {
108108
log.Fatal(err)
109109
}
@@ -195,8 +195,8 @@ func ExampleGQLClient() {
195195
}
196196

197197
// Add a star to the cli/go-gh repository using the GQL API.
198-
func ExampleGQLClient_mutate_simple() {
199-
client, err := gh.GQLClient(nil)
198+
func ExampleGQLClient_mutate() {
199+
client, err := api.DefaultGQLClient()
200200
if err != nil {
201201
log.Fatal(err)
202202
}
@@ -231,7 +231,7 @@ func ExampleGQLClient_mutate_simple() {
231231

232232
// Query releases from cli/cli repository using GQL API with paginated results.
233233
func ExampleGQLClient_pagination() {
234-
client, err := gh.GQLClient(nil)
234+
client, err := api.DefaultGQLClient()
235235
if err != nil {
236236
log.Fatal(err)
237237
}

pkg/api/cache_test.go

+12-6
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,17 @@ func TestCacheResponse(t *testing.T) {
3131

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

34-
httpClient, _ := NewHTTPClient(
34+
httpClient, err := NewHTTPClient(
3535
ClientOptions{
36+
Host: "github.com",
37+
AuthToken: "token",
3638
Transport: fakeHTTP,
3739
EnableCache: true,
3840
CacheDir: cacheDir,
3941
LogIgnoreEnv: true,
40-
})
42+
},
43+
)
44+
assert.NoError(t, err)
4145

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

5963
var res string
60-
var err error
6164

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

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

115-
httpClient, _ := NewHTTPClient(
118+
httpClient, err := NewHTTPClient(
116119
ClientOptions{
120+
Host: "github.com",
121+
AuthToken: "token",
117122
Transport: fakeHTTP,
118123
EnableCache: false,
119124
CacheDir: cacheDir,
120125
LogIgnoreEnv: true,
121-
})
126+
},
127+
)
128+
assert.NoError(t, err)
122129

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

142149
var res string
143-
var err error
144150

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

0 commit comments

Comments
 (0)