Use the mocks for tests and benchmarks.

This commit is contained in:
2024-09-13 21:27:34 +01:00
parent 7a791965ca
commit 50c1033ad1
5 changed files with 126 additions and 158 deletions
+19 -2
View File
@@ -36,10 +36,15 @@ func Benchmark_convertToJson(bn *testing.B) {
b.convertToJSON(query)
}
}
func Benchmark_Query(bn *testing.B) {
mockServer := StartMockServer()
bn.Cleanup(func() {
mockServer.Close()
})
b := NewConnection()
query := `query { viewer { login } }`
b.SetEndpoint(mockServer.URL)
query := "query { viewer { login } }"
variables := map[string]interface{}{
"var1": "value1",
}
@@ -54,7 +59,13 @@ func Benchmark_Query(bn *testing.B) {
}
func Benchmark_QueryNoCacheNoRetry(bn *testing.B) {
mockServer := StartMockServer()
bn.Cleanup(func() {
mockServer.Close()
})
b := NewConnection()
b.SetEndpoint(mockServer.URL)
query := `query { viewer { login } }`
variables := map[string]interface{}{
"var1": "value1",
@@ -69,7 +80,13 @@ func Benchmark_QueryNoCacheNoRetry(bn *testing.B) {
}
func Benchmark_QueryWithEmptyVariables(bn *testing.B) {
mockServer := StartMockServer()
bn.Cleanup(func() {
mockServer.Close()
})
b := NewConnection()
b.SetEndpoint(mockServer.URL)
query := `query { viewer { login } }`
headers := map[string]interface{}{
"Authorization": "Bearer token",