@@ -5,19 +5,12 @@ import (
55 "errors"
66 "io/ioutil"
77 "net/http"
8- "reflect"
98 "testing"
109
1110 "github.com/cli/cli/pkg/httpmock"
11+ "github.com/stretchr/testify/assert"
1212)
1313
14- func eq (t * testing.T , got interface {}, expected interface {}) {
15- t .Helper ()
16- if ! reflect .DeepEqual (got , expected ) {
17- t .Errorf ("expected: %v, got: %v" , expected , got )
18- }
19- }
20-
2114func TestGraphQL (t * testing.T ) {
2215 http := & httpmock.Registry {}
2316 client := NewClient (
@@ -38,13 +31,13 @@ func TestGraphQL(t *testing.T) {
3831 )
3932
4033 err := client .GraphQL ("github.com" , "QUERY" , vars , & response )
41- eq (t , err , nil )
42- eq (t , response .Viewer .Login , "hubot" )
34+ assert . NoError (t , err )
35+ assert . Equal (t , "hubot" , response .Viewer .Login )
4336
4437 req := http .Requests [0 ]
4538 reqBody , _ := ioutil .ReadAll (req .Body )
46- eq (t , string ( reqBody ), `{"query":"QUERY","variables":{"name":"Mona"}}` )
47- eq (t , req .Header .Get ("Authorization" ), "token OTOKEN" )
39+ assert . Equal (t , `{"query":"QUERY","variables":{"name":"Mona"}}` , string ( reqBody ) )
40+ assert . Equal (t , "token OTOKEN" , req .Header .Get ("Authorization" ))
4841}
4942
5043func TestGraphQLError (t * testing.T ) {
@@ -84,7 +77,7 @@ func TestRESTGetDelete(t *testing.T) {
8477
8578 r := bytes .NewReader ([]byte (`{}` ))
8679 err := client .REST ("github.com" , "DELETE" , "applications/CLIENTID/grant" , r , nil )
87- eq (t , err , nil )
80+ assert . NoError (t , err )
8881}
8982
9083func TestRESTError (t * testing.T ) {
0 commit comments