Skip to content

Commit ec563af

Browse files
committed
PR feedback
1 parent d3826b6 commit ec563af

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

api/query_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -384,9 +384,10 @@ func TestResponseCompression(t *testing.T) {
384384
assert.Equal(t, "application/json", res.Header.Get("Content-Type"))
385385
}
386386

387-
// fixLatencyMetric is a helper function that fixes the latency metric in the actual metrics. Since latency is non-deterministic, it can cause
388-
// tests to fail. This function replaces the latency metric in the actual metrics with the expected value, so that the test can pass.
389-
// It also asserts that the actual latency is less than the max value, to ensure that the latency is within acceptable limits.
387+
// fixLatencyMetric is a helper function that fixes the non-deterministic latency to ensure actual==expected for assertions.
388+
// Since latency is non-deterministic, it can cause tests to fail intermittently. This function replaces the latency metric
389+
// in the "expect" metrics with the "actual" value, so that the test can pass.
390+
// It also asserts that the actual latency is between 0 and the provided max value, to ensure that the latency is within acceptable limits.
390391
func fixLatencyMetric(t *testing.T, max int, expect, actual []mock.MetricMethodArgs) {
391392
t.Helper()
392393
if len(actual) != len(expect) {
@@ -395,7 +396,6 @@ func fixLatencyMetric(t *testing.T, max int, expect, actual []mock.MetricMethodA
395396
}
396397
for i, _ := range actual {
397398
if actual[i].Metric == metrics.LatencyMs && expect[i].Metric == metrics.LatencyMs && actual[i].Method == expect[i].Method {
398-
// Replace the latency metric with the expected value.
399399
assert.True(t, actual[i].IntVal >= 0 && actual[i].IntVal <= int64(max), "Latency metric value %d must be between 0 and %d.", actual[i].IntVal, max)
400400
expect[i].IntVal = actual[i].IntVal
401401
}

0 commit comments

Comments
 (0)