Skip to content

Add NIO APNSClient send coverage against APNSTestServer - #242

Merged
kylebrowning merged 1 commit into
mainfrom
test/nio-client-coverage
Jun 26, 2026
Merged

Add NIO APNSClient send coverage against APNSTestServer#242
kylebrowning merged 1 commit into
mainfrom
test/nio-client-coverage

Conversation

@kylebrowning

Copy link
Copy Markdown
Owner

Problem

The NIO-based APNSClient send path had effectively no functional testsAPNSClientTests only covers testShutdown plus a compile-only actor check — even though APNSTestServer already exists and is used by the broadcast client. Regressions in header construction or the success/error branch would go unnoticed.

Changes

  • New APNSClientSendTests exercising APNSClient.send end-to-end against APNSTestServer:
    • successful send returns a response + records the notification
    • full request-header propagation: apns-push-type, apns-topic, apns-priority, apns-expiration, apns-collapse-id
    • bad-device-token → 400 BadDeviceToken
    • missing-topic → 400 MissingTopic
    • 410 Unregistered including APNSError.timestamp decoding
  • APNSTestServer gains a small simulation hook: a valid-hex token equal to unregisteredDeviceToken responds 410 Unregistered with a timestamp, so the timestamp path is testable.

Testing

swift test — 77 tests pass.

The NIO-based `APNSClient` send path had effectively no functional tests — only
`testShutdown` and a compile-only actor check — even though `APNSTestServer`
already exists and is used by the broadcast client.

- Add `APNSClientSendTests` covering: successful send, full request-header
  propagation (push-type, topic, priority, expiration, collapse-id), the
  bad-device-token and missing-topic error branches, and the `410 Unregistered`
  path including `APNSError.timestamp` decoding.
- Teach `APNSTestServer` to simulate an unregistered token: a valid-hex token
  equal to `unregisteredDeviceToken` returns `410 Unregistered` with a
  `timestamp`, so the timestamp decoding path is exercisable.
@kylebrowning
kylebrowning merged commit 356534b into main Jun 26, 2026
6 checks passed
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.

1 participant