Skip to content

Commit 292e080

Browse files
committed
fix json equality
1 parent 7a0f11b commit 292e080

File tree

1 file changed

+23
-4
lines changed

1 file changed

+23
-4
lines changed

test/telemetry/test_telemetry.cpp

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -389,7 +389,14 @@ TELEMETRY_IMPLEMENTATION_TEST("Tracer telemetry API") {
389389
}
390390
]
391391
)");
392-
CHECK(series == expected_metrics);
392+
393+
for (const auto& s : series) {
394+
if (s.contains("tags")) {
395+
CHECK(s == expected_metrics[0]);
396+
} else {
397+
CHECK(s == expected_metrics[1]);
398+
}
399+
}
393400

394401
// Make sure the next heartbeat doesn't contains counters if no
395402
// datapoint has been incremented, decremented or set.
@@ -438,7 +445,7 @@ TELEMETRY_IMPLEMENTATION_TEST("Tracer telemetry API") {
438445
}
439446
]
440447
)");
441-
CHECK(series == expected_metrics);
448+
CHECK(is_same_json(series, expected_metrics));
442449
}
443450

444451
SECTION("rate") {
@@ -494,7 +501,7 @@ TELEMETRY_IMPLEMENTATION_TEST("Tracer telemetry API") {
494501
}
495502
]
496503
)");
497-
CHECK(series == expected_metrics);
504+
CHECK(is_same_json(series, expected_metrics));
498505

499506
// Make sure the next heartbeat doesn't contains distributions if no
500507
// datapoint has been added to a distribution.
@@ -563,7 +570,19 @@ TELEMETRY_IMPLEMENTATION_TEST("Tracer telemetry API") {
563570
}
564571
])");
565572

566-
CHECK(distribution_series == expected_series);
573+
for (const auto& s : distribution_series) {
574+
if (s["metric"] == "response_time") {
575+
if (s.contains("tags")) {
576+
CHECK(s == expected_series[0]);
577+
} else {
578+
CHECK(s == expected_series[2]);
579+
}
580+
} else if (s["metric"] == "request_size") {
581+
CHECK(s == expected_series[1]);
582+
} else {
583+
FAIL();
584+
}
585+
}
567586

568587
// Make sure the next heartbeat doesn't contains distributions if no
569588
// datapoint has been added to a distribution.

0 commit comments

Comments
 (0)