From f903b320af616694b0db670da14185b027824d00 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Bombeck?= Date: Mon, 15 Jun 2026 02:11:04 +0200 Subject: [PATCH] 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. --- tests/integration/measurement-rollups.test.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/tests/integration/measurement-rollups.test.ts b/tests/integration/measurement-rollups.test.ts index b911cffe1..6fc26b3b2 100644 --- a/tests/integration/measurement-rollups.test.ts +++ b/tests/integration/measurement-rollups.test.ts @@ -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); } } });