fix tests
This commit is contained in:
parent
0af61ff1ff
commit
425f707c7d
3 changed files with 10 additions and 8 deletions
|
|
@ -26,9 +26,6 @@ func listGists(client *http.Client, hostname string, limit int, visibility strin
|
|||
return nil, err
|
||||
}
|
||||
|
||||
// TODO in tests the api call is matching properly and encoding json properly but i'm getting no
|
||||
// result and no parse error, wtf?
|
||||
|
||||
gists := []shared.Gist{}
|
||||
|
||||
for _, gist := range result {
|
||||
|
|
|
|||
|
|
@ -88,14 +88,13 @@ func TestNewCmdList(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
// TODO execution tests
|
||||
|
||||
func Test_listRun(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
opts *ListOptions
|
||||
wantOut string
|
||||
stubs func(*httpmock.Registry)
|
||||
nontty bool
|
||||
}{
|
||||
{
|
||||
name: "no gists",
|
||||
|
|
@ -116,6 +115,7 @@ func Test_listRun(t *testing.T) {
|
|||
// TODO public filter
|
||||
// TODO secret filter
|
||||
// TODO limit specified
|
||||
// TODO nontty output
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
|
|
@ -149,8 +149,16 @@ func Test_listRun(t *testing.T) {
|
|||
}
|
||||
|
||||
io, _, stdout, _ := iostreams.Test()
|
||||
io.SetStdoutTTY(!tt.nontty)
|
||||
tt.opts.IO = io
|
||||
|
||||
if tt.opts.Limit == 0 {
|
||||
tt.opts.Limit = 10
|
||||
}
|
||||
|
||||
if tt.opts.Visibility == "" {
|
||||
tt.opts.Visibility = "all"
|
||||
}
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
err := listRun(tt.opts)
|
||||
assert.NoError(t, err)
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@ package httpmock
|
|||
import (
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
|
|
@ -87,8 +86,6 @@ func StatusStringResponse(status int, body string) Responder {
|
|||
func JSONResponse(body interface{}) Responder {
|
||||
return func(req *http.Request) (*http.Response, error) {
|
||||
b, _ := json.Marshal(body)
|
||||
fmt.Printf("DEBUG %#v\n", "COOOOOL")
|
||||
fmt.Printf("DEBUG %#v\n", string(b))
|
||||
return httpResponse(200, req, bytes.NewBuffer(b)), nil
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue