Replace source-string regression tests with behavioral tests (idle_reporting_regression_test.go) #26

Open
opened 2026-05-12 09:34:44 +02:00 by heiko · 1 comment
Owner

Found during review of #24.

cmd/xr-invoiced/idle_reporting_regression_test.go reads Go source files (main.go, internal/scanner/scanner.go) and uses strings.Contains to assert on literal fragments like ReportProcessed: true, Source: "initial", and logger = logger.With("mailbox", mailbox).

Problems:

  • Any innocuous refactor (renaming a local, reordering struct fields, extracting a helper) breaks the test with no useful signal.
  • The tests don't actually exercise IDLE-wakeup reporting or scan-source labeling at runtime.

This repo already drives real IMAP behavior with imapmemserver in other tests. Replace these with behavior tests that:

  • run an IDLE wakeup and assert the captured log output contains scan=idle for every processed UID;
  • run ScanAll and assert scan=initial is emitted;
  • assert that runMailbox's log records have a mailbox attr.

At minimum, if these stay as deliberate sentinels, add a comment explaining what real test should replace them.

Refs: PR #24

Found during review of #24. `cmd/xr-invoiced/idle_reporting_regression_test.go` reads Go source files (`main.go`, `internal/scanner/scanner.go`) and uses `strings.Contains` to assert on literal fragments like `ReportProcessed: true`, `Source: "initial"`, and `logger = logger.With("mailbox", mailbox)`. Problems: - Any innocuous refactor (renaming a local, reordering struct fields, extracting a helper) breaks the test with no useful signal. - The tests don't actually exercise IDLE-wakeup reporting or scan-source labeling at runtime. This repo already drives real IMAP behavior with `imapmemserver` in other tests. Replace these with behavior tests that: - run an IDLE wakeup and assert the captured log output contains `scan=idle` for every processed UID; - run `ScanAll` and assert `scan=initial` is emitted; - assert that `runMailbox`'s log records have a `mailbox` attr. At minimum, if these stay as deliberate sentinels, add a comment explaining what real test should replace them. Refs: PR #24
Author
Owner

Related commit: 2305c33. The current regression test is still source-string based, so the behavioral-test refactor described here is not yet done.

Related commit: 2305c33. The current regression test is still source-string based, so the behavioral-test refactor described here is not yet done.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
IUS/xr-invoiced#26
No description provided.