Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR refactors the test suite and updates the EventSource API to make callbacks async. The main changes include:
- Test function naming: Removes "test" prefix from test function names across all test files, aligning with Swift Testing conventions
- Async callbacks: Changes EventSource callbacks (
onOpen,onMessage,onError) from synchronous to async functions - Event delivery: Adds explicit event delivery loop after
parser.finish()to ensure pending events are delivered with a safety limit of 100 events - Test organization: Reorganizes
IntegrationTests.swiftinto clearer nested suites:EventSourceAPITestsandURLSessionBytesAPITests
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| Tests/EventSourceTests/ParserTests.swift | Renamed all test functions to remove "test" prefix for consistency with Swift Testing conventions |
| Tests/EventSourceTests/IntegrationTests.swift | Renamed tests, reorganized into nested suites, updated to use async callbacks, removed unused ErrorTracker actor |
| Tests/EventSourceTests/AsyncEventsSequenceTests.swift | Renamed all test functions to remove "test" prefix |
| Sources/EventSource/EventSource.swift | Changed callbacks to async, added event delivery loop after parser.finish(), removed some explanatory comments |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR attempts to fix an apparent race condition indicated by a flakey integration test by making the
onMessagecallbackasyncand awaiting that before proceeding with reconnection or completion.It also adds a new
maximumFinalizationEventCountproperty (default = 100) to prevent unbounded memory growth when handling events sent by the server during finalization.