Skip to content

Follow the shared poll-delay rules and test them offline - #32

Merged
jm-mailosaur merged 4 commits into
mainfrom
claude/poll-delay-spec
Dec 4, 2026
Merged

jm-mailosaur merged 4 commits into
mainfrom
claude/poll-delay-spec

Conversation

@jm-mailosaur

@jm-mailosaur jm-mailosaur commented Dec 4, 2026 •

Copy link
Copy Markdown
Contributor

Problem

Messages.search and Files.getPreview parse each x-ms-delay entry with Integer.parseInt, so an empty or non-numeric entry throws NumberFormatException out of polling. No test covers poll delays.

Changes

  1. Search and preview read x-ms-delay through one package-private pollDelay in MailosaurClient. Poll n uses entry n, the last entry repeats, and each wait is used exactly as given, in milliseconds.
  2. An entry counts only if, after trimming, it is ASCII digits that fit an int. Anything else (a sign, decimal, hex, units, letters, an empty entry) or no header waits 1000 ms. 0 means no wait.
  3. Package-private hooks let tests swap the HTTP transport, sleep and clock, so the public API is unchanged.
  4. PollingTest adds the 9 poll-delay tests (5 search, 4 preview) that every Mailosaur client shares. They run offline with MockHttpTransport and a fake clock (mvn test -Dtest=PollingTest), and fail after 20 requests instead of hanging.
  5. Error types and messages are unchanged.
  6. The same rules and the same 9 tests (5 search, 4 preview) are going into all ten Mailosaur clients.

Search and preview polling now read x-ms-delay through one package-private
pollDelay function. An entry that is empty, negative or not a number counts
as 1000 ms instead of throwing NumberFormatException.

Package-private hooks let tests swap the HTTP transport, sleep and clock
without changing the public API. PollingTest covers the shared spec's 14
cases with MockHttpTransport and a fake clock, so it runs without secrets:
mvn test -Dtest=PollingTest
A delay entry now counts only when it is one or more ASCII digits after
trimming. Signs, decimals, hex, units, non-ASCII digits and values too big
for an int count as 1000 ms, as before for other non-numbers.

PollingTest moves to the shared spec's 18 cases: wider not-a-number
coverage, elapsed time measured in milliseconds, and the delay read from
the latest response. The stub transport fails a test after 20 requests,
so a broken timeout check fails instead of hanging.
The search tests that end in a match now check that the result holds
exactly one item, match-id, so an extra item fails the test.
Parsing is shared, so preview keeps only tests of its own loop. The
search and preview timeout tests now use delays whose sum just passes
the timeout, so they also catch elapsed time counted in whole seconds
or checked only after the timeout has passed.
@jm-mailosaur
jm-mailosaur merged commit 339c763 into main Dec 4, 2026
5 checks passed
@jm-mailosaur
jm-mailosaur deleted the claude/poll-delay-spec branch December 4, 2026 18:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants