test(rollups): compare rounded rollup means to live SQL within hundredths, not bit-for-bit

The rollup tier rounds its bucket mean to two decimals and live SQL rounds the
full-day AVG to two decimals; rounding through different intermediate paths can
land one cent apart on a half-cent boundary, so the 5-decimal toBeCloseTo was a
data-dependent flake. Assert to within a few hundredths; min/max stay exact.
This commit is contained in:
Marc-André Bombeck committed 2026-06-15 02:11:04 +02:00
1 parent cbd5c2ba6f
commit f903b320af
1 file changed
+6 -2
@@ -458,8 +458,12 @@ describe("measurement rollups — integration", () => {
expect(rollupDaily!.length).toBe(liveDaily.length);
for (let i = 0; i < liveDaily.length; i++) {
expect(rollupDaily![i].day).toBe(liveDaily[i].day);
// round2 of the bucket mean == ROUND(AVG, 2) of the same rows.
expect(rollupDaily![i].value).toBeCloseTo(liveDaily[i].value, 5);
// The rollup rounds its bucket mean to two decimals; live SQL rounds
// the full-day AVG to two decimals. Both are 2-decimal, but rounding
// through different intermediate paths can land one cent apart on a
// half-cent boundary — so assert agreement to within a few hundredths,
// not bit-for-bit. min/max above stay exact.
expect(rollupDaily![i].value).toBeCloseTo(liveDaily[i].value, 1);
}
}
});