-
Notifications
You must be signed in to change notification settings - Fork 469
Improve abort tests across all SDKs; add Go unsubscribe tests #48
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
e0e1822 to
1ffd814
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR adds comprehensive unit tests for the Session.On() event handler subscription and unsubscription functionality. The tests are designed to validate the fix from PR #24, which addressed an issue with invalid function pointer comparison in the unsubscribe mechanism.
Changes:
- Added new test file
go/session_test.gowith 5 test cases covering event handler subscription/unsubscription - Tests verify multiple handlers, selective unsubscription, idempotent unsubscribe, handler ordering, and concurrent safety
Comments suppressed due to low confidence (4)
go/session_test.go:81
- The type
sessionHandlerdoes not exist. The Session struct's handlers field is of type[]SessionEventHandler(uppercase 'S'). This will cause a compilation error. ChangesessionHandlertoSessionEventHandler.
handlers: make([]sessionHandler, 0),
go/session_test.go:98
- The type
sessionHandlerdoes not exist. The Session struct's handlers field is of type[]SessionEventHandler(uppercase 'S'). This will cause a compilation error. ChangesessionHandlertoSessionEventHandler.
handlers: make([]sessionHandler, 0),
go/session_test.go:11
- The type
sessionHandlerdoes not exist. The Session struct's handlers field is of type[]SessionEventHandler(uppercase 'S'). This will cause a compilation error. ChangesessionHandlertoSessionEventHandler.
handlers: make([]sessionHandler, 0),
go/session_test.go:29
- The type
sessionHandlerdoes not exist. The Session struct's handlers field is of type[]SessionEventHandler(uppercase 'S'). This will cause a compilation error. ChangesessionHandlertoSessionEventHandler.
handlers: make([]sessionHandler, 0),
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
1ffd814 to
520d8fb
Compare
The unsubscribe function was failing due to invalid function pointer comparisons. Refactored handler registration to use unique IDs for reliable cleanup. Tests verify: - Multiple handlers can be registered and all receive events - Unsubscribing one handler doesn't affect others - Calling unsubscribe multiple times is safe - Handlers are called in registration order - Concurrent subscribe/unsubscribe is safe Co-authored-by: nathfavour <116535483+nathfavour@users.noreply.github.com>
520d8fb to
3a8c2a5
Compare
Continuation of #24 (thanks, @nathfavour!)
Previously we didn't have proper
aborttests because the CLI didn't produce the events we expected. But now it does.