Skip to content

Remove duplicate @fedify/cfworkers tests and record where new ones belong #1048

Description

@dahlia

@fedify/cfworkers tests the same classes twice. packages/cfworkers/src/mod.test.ts drives them through hand-written mocks; packages/cfworkers/test/mq.test.ts and packages/cfworkers/test/kv.test.ts drive them through the miniflare bindings that packages/cfworkers/wrangler.jsonc declares. Nothing records which file a new test belongs in, so tests keep landing in both.

All four WorkersMessageQueue tests in src/mod.test.ts are now covered by test/mq.test.ts:

  • enqueue() sends __fedify_ordering_key__ and __fedify_payload__ to the queue binding duplicates enqueue() with ordering key, which additionally asserts the send() options.
  • processMessage() - returns shouldProcess=false when lock exists duplicates returns shouldProcess=false when lock exists.
  • processMessage() - release() frees the ordering lock covers the same acquire-and-release cycle as acquires lock and processes message with ordering key, adding only an assertion that the next message gets through.
  • listen() throws TypeError duplicates the test of the same name, asserting the whole error message where the other asserts a prefix.

#1023 followed #878 as written. #878 asked for enqueueMany() coverage that test/mq.test.ts already had, so the three tests it added to src/mod.test.ts land on top of existing ones. Adding a stray field to the wrapper inside enqueueMany() fails the new tests and the existing ones together, so the new ones catch nothing the suite was missing.

The copies in src/mod.test.ts also test less of the binding contract. test/mq.test.ts spies on env.Q1, the real queue producer binding, so it asserts against the actual Queue API surface. A hand-written mock keeps passing when that surface changes.

Delete the duplicates after deciding which kind of test belongs in each file. Record that rule in a comment at the top of both files. One split that fits the current code: src/mod.test.ts keeps logic that needs no binding, and anything asserting what goes out to a queue or a KV namespace lives under test/.

Suggested check: mise run check-each cfworkers.

No activity

Activity on this issue will appear here.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

Fields

Priority

None yet

Effort

None yet

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions