From 9946c0f1d81674509f400d3f873a9d176ac2f906 Mon Sep 17 00:00:00 2001 From: David Fifield Date: Fri, 15 Aug 2025 19:02:07 +0000 Subject: [PATCH] Add a test for formatAndClearCountryStats with binned=true. --- broker/metrics_test.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/broker/metrics_test.go b/broker/metrics_test.go index 2507299..0715aad 100644 --- a/broker/metrics_test.go +++ b/broker/metrics_test.go @@ -30,6 +30,10 @@ func TestFormatAndClearCountryStats(t *testing.T) { So(formatAndClearCountryStats(stats, false), ShouldEqual, "CN=250,FR=200,RU=150,TZ=100,IT=50,BE=1,CA=1,PH=1") }) + Convey("the order should be correct with binned=true", func() { + So(formatAndClearCountryStats(stats, true), ShouldEqual, "CN=256,FR=200,RU=152,TZ=104,IT=56,BE=8,CA=8,PH=8") + }) + // The map should be cleared on return. stats.Range(func(_, _ any) bool { panic("map was not cleared") }) })