Copilot commented on code in PR #1242:
URL: 
https://github.com/apache/rocketmq-client-go/pull/1242#discussion_r3923586502


##########
consumer/statistics_test.go:
##########
@@ -226,3 +226,19 @@ func TestNewStatsManager(t *testing.T) {
        }
        stats.ShutDownStat()
 }
+
+// TestSamplingInHourTrimsDayList verifies that samplingInHour keeps the day
+// snapshot list bounded. samplingInHour appends to csListDay, so it must also
+// trim csListDay once it grows beyond 25 entries. A copy-paste slip that 
trimmed
+// csListHour instead is a no-op (the removed element does not belong to
+// csListHour), which lets csListDay grow without bound and corrupts the
+// day-window statistics.
+func TestSamplingInHourTrimsDayList(t *testing.T) {
+       si := newStatsItem("test", "key")
+       for i := 0; i < 30; i++ {
+               si.samplingInHour()
+       }
+       if got := si.csListDay.Len(); got != 25 {

Review Comment:
   This test only asserts the final cap, which is good as a regression, but it 
doesn’t verify the boundary behavior at the exact threshold (e.g., length is 25 
at 25 samples and remains 25 at 26). Adding a couple of focused assertions 
around the boundary makes the intent clearer and helps diagnose off-by-one 
regressions faster.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to