Skip to content

Commit

Permalink
fixup! Update dependencies Fix go mod version in mod file.
Browse files Browse the repository at this point in the history
  • Loading branch information
lukaszraczylo committed Dec 12, 2023
1 parent ef4ab45 commit ac957ac
Show file tree
Hide file tree
Showing 2 changed files with 78 additions and 1 deletion.
65 changes: 64 additions & 1 deletion helpers_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
package gql

import "testing"
import (
"reflect"
"testing"
)

func (suite *Tests) Test_searchForKeysInMapStringInterface() {
type args struct {
Expand Down Expand Up @@ -41,3 +44,63 @@ func (suite *Tests) Test_searchForKeysInMapStringInterface() {
})
}
}

func (suite *Tests) TestBaseClient_decodeResponse() {
type args struct {
response []byte
}
tests := []struct {
name string
args args
want any
wantErr bool
setType string
wantType string
}{
{
name: "TestBaseClient_decodeResponse_mapstring",
args: args{
response: []byte(`{"data":{"viewer":{"login":"lukaszraczylo"}}}`),
},
want: map[string]interface{}{
"data": map[string]interface{}{
"viewer": map[string]interface{}{
"login": "lukaszraczylo",
},
},
},
setType: "mapstring",
wantType: "map[string]interface {}",
},
{
name: "TestBaseClient_decodeResponse_string",
args: args{
response: []byte(`{"data":{"viewer":{"login":"lukaszraczylo"}}}`),
},
want: `{"data":{"viewer":{"login":"lukaszraczylo"}}}`,
setType: "string",
wantType: "string",
},
{
name: "TestBaseClient_decodeResponse_byte",
args: args{
response: []byte(`{"data":{"viewer":{"login":"lukaszraczylo"}}}`),
},
want: []byte(`{"data":{"viewer":{"login":"lukaszraczylo"}}}`),
setType: "byte",
wantType: "[]uint8",
},
}
for _, tt := range tests {
suite.T().Run(tt.name, func(t *testing.T) {
b := NewConnection()
b.SetOutput(tt.setType)
got, err := b.decodeResponse(tt.args.response)
if (err != nil) != tt.wantErr {
t.Errorf("decodeResponse() error = %v, wantErr %v", err, tt.wantErr)
return
}
assert.Equal(tt.wantType, reflect.TypeOf(got).String())
})
}
}
14 changes: 14 additions & 0 deletions query_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,20 @@ func (suite *Tests) TestBaseClient_Query() {
wantReturned_value: []byte(`{"__type":null}`),
wantErr: false,
},
{
name: "TestBaseClient_Query_tgbotapp_valid_query_string",
graphQLServer: "https://telegram-bot.app/v1/graphql",
wantType: "string",
args: args{
query: `query {
__type(name: "Query") {
name
}
}`,
},
wantReturned_value: string(`{"__type":null}`),
wantErr: false,
},
{
name: "TestBaseClient_Query_tgbotapp_valid_query_invalid_type",
graphQLServer: "https://telegram-bot.app/v1/graphql",
Expand Down

0 comments on commit ac957ac

Please sign in to comment.