@@ -30,7 +30,7 @@ func TestBenchSpy_NewGeneratorQueryExecutor(t *testing.T) {
3030 }
3131 executor , err := NewGeneratorQueryExecutor (gen )
3232 assert .NoError (t , err )
33- assert .Equal (t , "generator" , executor .Kind )
33+ assert .Equal (t , "generator" , executor .KindName )
3434 assert .Equal (t , gen , executor .Generator )
3535 assert .NotEmpty (t , executor .Queries )
3636 assert .NotNil (t , executor .QueryResults )
@@ -49,8 +49,8 @@ func TestBenchSpy_NewGeneratorQueryExecutor(t *testing.T) {
4949}
5050
5151func TestBenchSpy_GeneratorQueryExecutor_Results (t * testing.T ) {
52- expected := map [string ][] string {
53- "test" : { "result" } ,
52+ expected := map [string ]interface {} {
53+ "test" : "result" ,
5454 }
5555 executor := & GeneratorQueryExecutor {
5656 QueryResults : expected ,
@@ -235,27 +235,24 @@ func TestBenchSpy_GeneratorQueryExecutor_Execute(t *testing.T) {
235235 // 4 responses with ~150ms latency (150ms sleep + some execution overhead)
236236 // and 2-3 responses with ~200ms latency (200ms sleep + some execution overhead)
237237 // expected median latency: (150ms, 151ms>
238- medianLatency , exists := results [ string (MedianLatency )]
239- assert . True (t , exists )
238+ resultsAsStrings := ResultsAs ( "string" , [] QueryExecutor { executor }, StandardQueryExecutor_Generator , string (MedianLatency ), string ( Percentile95Latency ), string ( ErrorRate ))
239+ require . Equal (t , 3 , len ( resultsAsStrings ) )
240240
241- medianLatencyFloat , err := strconv .ParseFloat (medianLatency [ 0 ], 64 )
241+ medianLatencyFloat , err := strconv .ParseFloat (resultsAsStrings [ string ( MedianLatency ) ], 64 )
242242 assert .NoError (t , err )
243243 require .InDelta (t , 151.0 , medianLatencyFloat , 1.0 )
244244
245- p95Latency , exists := results [string (Percentile95Latency )]
246- assert .True (t , exists )
247-
248245 // since we have 2-3 responses with 200-201ms latency, the 95th percentile should be (200ms, 201ms>
249- p95LatencyFloat , err := strconv .ParseFloat (p95Latency [ 0 ], 64 )
246+ p95LatencyFloat , err := strconv .ParseFloat (resultsAsStrings [ string ( Percentile95Latency ) ], 64 )
250247 assert .NoError (t , err )
251248 require .InDelta (t , 201.0 , p95LatencyFloat , 1.0 )
252249
253- errorRate , exists := results [string (ErrorRate )]
250+ errorRate , exists := resultsAsStrings [string (ErrorRate )]
254251 assert .True (t , exists )
255252
256253 // error rate is the number of failures divided by the total number of responses
257254 expectedErrorRate := float64 (actualFailures ) / (float64 (fakeGun .maxSuccesses ) + float64 (actualFailures ))
258- assert .Equal (t , [] string { fmt .Sprintf ("%.4f" , expectedErrorRate )} , errorRate )
255+ assert .Equal (t , fmt .Sprintf ("%.4f" , expectedErrorRate ), errorRate )
259256 })
260257
261258 t .Run ("all responses failed" , func (t * testing.T ) {
@@ -345,15 +342,15 @@ func TestBenchSpy_GeneratorQueryExecutor_MarshalJSON(t *testing.T) {
345342 },
346343 }
347344 original , _ := NewGeneratorQueryExecutor (gen )
348- original .QueryResults ["test" ] = [] string { "result" }
349- original .QueryResults ["test2" ] = [] string { "1" , "2" , "3" }
345+ original .QueryResults ["test" ] = "result"
346+ original .QueryResults ["test2" ] = "1"
350347
351348 original .Queries = map [string ]GeneratorQueryFn {
352349 "test" : func (responses * wasp.SliceBuffer [wasp.Response ]) (string , error ) {
353350 return "result" , nil
354351 },
355352 "test2" : func (responses * wasp.SliceBuffer [wasp.Response ]) (string , error ) {
356- return "1,2,3 " , nil
353+ return "1" , nil
357354 },
358355 }
359356
0 commit comments