Skip to content

Commit 425f707

Browse files
committed
fix tests
1 parent 0af61ff commit 425f707

File tree

3 files changed

+10
-8
lines changed

3 files changed

+10
-8
lines changed

pkg/cmd/gist/list/http.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,6 @@ func listGists(client *http.Client, hostname string, limit int, visibility strin
2626
return nil, err
2727
}
2828

29-
// TODO in tests the api call is matching properly and encoding json properly but i'm getting no
30-
// result and no parse error, wtf?
31-
3229
gists := []shared.Gist{}
3330

3431
for _, gist := range result {

pkg/cmd/gist/list/list_test.go

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,14 +88,13 @@ func TestNewCmdList(t *testing.T) {
8888
}
8989
}
9090

91-
// TODO execution tests
92-
9391
func Test_listRun(t *testing.T) {
9492
tests := []struct {
9593
name string
9694
opts *ListOptions
9795
wantOut string
9896
stubs func(*httpmock.Registry)
97+
nontty bool
9998
}{
10099
{
101100
name: "no gists",
@@ -116,6 +115,7 @@ func Test_listRun(t *testing.T) {
116115
// TODO public filter
117116
// TODO secret filter
118117
// TODO limit specified
118+
// TODO nontty output
119119
}
120120

121121
for _, tt := range tests {
@@ -149,8 +149,16 @@ func Test_listRun(t *testing.T) {
149149
}
150150

151151
io, _, stdout, _ := iostreams.Test()
152+
io.SetStdoutTTY(!tt.nontty)
152153
tt.opts.IO = io
153154

155+
if tt.opts.Limit == 0 {
156+
tt.opts.Limit = 10
157+
}
158+
159+
if tt.opts.Visibility == "" {
160+
tt.opts.Visibility = "all"
161+
}
154162
t.Run(tt.name, func(t *testing.T) {
155163
err := listRun(tt.opts)
156164
assert.NoError(t, err)

pkg/httpmock/stub.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ package httpmock
33
import (
44
"bytes"
55
"encoding/json"
6-
"fmt"
76
"io"
87
"io/ioutil"
98
"net/http"
@@ -87,8 +86,6 @@ func StatusStringResponse(status int, body string) Responder {
8786
func JSONResponse(body interface{}) Responder {
8887
return func(req *http.Request) (*http.Response, error) {
8988
b, _ := json.Marshal(body)
90-
fmt.Printf("DEBUG %#v\n", "COOOOOL")
91-
fmt.Printf("DEBUG %#v\n", string(b))
9289
return httpResponse(200, req, bytes.NewBuffer(b)), nil
9390
}
9491
}

0 commit comments

Comments
 (0)