-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
cd5d75f
commit 13955da
Showing
7 changed files
with
193 additions
and
106 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,69 +1,69 @@ | ||
package gql | ||
|
||
import ( | ||
"testing" | ||
) | ||
// import ( | ||
// "testing" | ||
// ) | ||
|
||
func Benchmark_GraphQL_Query(t *testing.B) { | ||
if testing.Short() { | ||
t.Skip("Skipping test in short / CI mode") | ||
} | ||
type args struct { | ||
queryContent string | ||
queryVariables interface{} | ||
} | ||
tests := []struct { | ||
name string | ||
endpoint string | ||
isLocal bool | ||
args args | ||
wantResult string | ||
mockedReply string | ||
wantErr bool | ||
}{ | ||
{ | ||
name: "Valid query", | ||
endpoint: "http://hasura.local/v1/graphql", | ||
isLocal: false, | ||
args: args{ | ||
queryContent: `query listUserBots { | ||
tbl_bots(limit: 1) { | ||
bot_name | ||
} | ||
}`, | ||
queryVariables: nil, | ||
}, | ||
wantResult: `{"tbl_bots":[{"bot_name":"littleMentionBot"}]}`, | ||
mockedReply: `{"data":{"tbl_bots":[{"bot_name":"littleMentionBot"}]}}`, | ||
wantErr: false, | ||
}, | ||
{ | ||
name: "Invalid query", | ||
endpoint: "http://hasura.local/v1/graphql", | ||
isLocal: false, | ||
args: args{ | ||
queryContent: `query listUserBots { | ||
tbl_botz(limit: 1) { | ||
bot_name | ||
} | ||
}`, | ||
queryVariables: nil, | ||
}, | ||
mockedReply: `{"errors":[{"message":"Unknown field \"tbl_botz\" on type \"Query\""}]}`, | ||
wantResult: ``, | ||
wantErr: true, | ||
}, | ||
} | ||
// func Benchmark_GraphQL_Query(t *testing.B) { | ||
// if testing.Short() { | ||
// t.Skip("Skipping test in short / CI mode") | ||
// } | ||
// type args struct { | ||
// queryContent string | ||
// queryVariables interface{} | ||
// } | ||
// tests := []struct { | ||
// name string | ||
// endpoint string | ||
// isLocal bool | ||
// args args | ||
// wantResult string | ||
// mockedReply string | ||
// wantErr bool | ||
// }{ | ||
// { | ||
// name: "Valid query", | ||
// endpoint: "http://hasura.local/v1/graphql", | ||
// isLocal: false, | ||
// args: args{ | ||
// queryContent: `query listUserBots { | ||
// tbl_bots(limit: 1) { | ||
// bot_name | ||
// } | ||
// }`, | ||
// queryVariables: nil, | ||
// }, | ||
// wantResult: `{"tbl_bots":[{"bot_name":"littleMentionBot"}]}`, | ||
// mockedReply: `{"data":{"tbl_bots":[{"bot_name":"littleMentionBot"}]}}`, | ||
// wantErr: false, | ||
// }, | ||
// { | ||
// name: "Invalid query", | ||
// endpoint: "http://hasura.local/v1/graphql", | ||
// isLocal: false, | ||
// args: args{ | ||
// queryContent: `query listUserBots { | ||
// tbl_botz(limit: 1) { | ||
// bot_name | ||
// } | ||
// }`, | ||
// queryVariables: nil, | ||
// }, | ||
// mockedReply: `{"errors":[{"message":"Unknown field \"tbl_botz\" on type \"Query\""}]}`, | ||
// wantResult: ``, | ||
// wantErr: true, | ||
// }, | ||
// } | ||
|
||
for _, tt := range tests { | ||
t.Run(tt.name, func(t *testing.B) { | ||
g := NewConnection() | ||
server, serverURL := mockGraphQLServerResponses(tt.mockedReply) | ||
g.Endpoint = serverURL | ||
for n := 0; n < t.N; n++ { | ||
g.Query(tt.args.queryContent, tt.args.queryVariables, nil) | ||
} | ||
server.Close() | ||
}) | ||
} | ||
} | ||
// for _, tt := range tests { | ||
// t.Run(tt.name, func(t *testing.B) { | ||
// g := NewConnection() | ||
// server, serverURL := mockGraphQLServerResponses(tt.mockedReply) | ||
// g.Endpoint = serverURL | ||
// for n := 0; n < t.N; n++ { | ||
// g.Query(tt.args.queryContent, tt.args.queryVariables, nil) | ||
// } | ||
// server.Close() | ||
// }) | ||
// } | ||
// } |
Oops, something went wrong.