Skip to content

Conversation

@SteveSandersonMS
Copy link
Contributor

@SteveSandersonMS SteveSandersonMS commented Jan 19, 2026

Continuation of #24 (thanks, @nathfavour!)

Previously we didn't have proper abort tests because the CLI didn't produce the events we expected. But now it does.

  • Fix abort tests to properly wait for tool.execution_start before aborting
  • Add getNextEventOfType test helper to all SDK test harnesses
  • Move Go generated session event types from go/generated/ subpackage to main copilot package
  • Add unit tests for Go session event handler subscribe/unsubscribe

@SteveSandersonMS SteveSandersonMS requested a review from a team as a code owner January 19, 2026 13:49
Copilot AI review requested due to automatic review settings January 19, 2026 13:49
@SteveSandersonMS SteveSandersonMS force-pushed the stevesa/session-unsubscribe-tests branch from e0e1822 to 1ffd814 Compare January 19, 2026 13:49
Copy link
Contributor

Copilot AI left a 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.go with 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 sessionHandler does not exist. The Session struct's handlers field is of type []SessionEventHandler (uppercase 'S'). This will cause a compilation error. Change sessionHandler to SessionEventHandler.
			handlers: make([]sessionHandler, 0),

go/session_test.go:98

  • The type sessionHandler does not exist. The Session struct's handlers field is of type []SessionEventHandler (uppercase 'S'). This will cause a compilation error. Change sessionHandler to SessionEventHandler.
			handlers: make([]sessionHandler, 0),

go/session_test.go:11

  • The type sessionHandler does not exist. The Session struct's handlers field is of type []SessionEventHandler (uppercase 'S'). This will cause a compilation error. Change sessionHandler to SessionEventHandler.
			handlers: make([]sessionHandler, 0),

go/session_test.go:29

  • The type sessionHandler does not exist. The Session struct's handlers field is of type []SessionEventHandler (uppercase 'S'). This will cause a compilation error. Change sessionHandler to SessionEventHandler.
			handlers: make([]sessionHandler, 0),

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@SteveSandersonMS SteveSandersonMS changed the title Add unit tests for session event handler unsubscription Fix go session event handler unsubscription and add tests Jan 19, 2026
@SteveSandersonMS SteveSandersonMS force-pushed the stevesa/session-unsubscribe-tests branch from 1ffd814 to 520d8fb Compare January 19, 2026 14:32
@SteveSandersonMS SteveSandersonMS changed the title Fix go session event handler unsubscription and add tests Tests for go session event handler unsubscription Jan 19, 2026
SteveSandersonMS and others added 2 commits January 20, 2026 12:14
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>
@SteveSandersonMS SteveSandersonMS force-pushed the stevesa/session-unsubscribe-tests branch from 520d8fb to 3a8c2a5 Compare January 20, 2026 12:15
@SteveSandersonMS SteveSandersonMS changed the title Tests for go session event handler unsubscription Improve abort tests across all SDKs; move Go generated code into public API Jan 20, 2026
@SteveSandersonMS SteveSandersonMS changed the title Improve abort tests across all SDKs; move Go generated code into public API Improve abort tests across all SDKs Jan 20, 2026
@SteveSandersonMS SteveSandersonMS changed the title Improve abort tests across all SDKs Improve abort tests across all SDKs; add Go unsubscribe tests Jan 20, 2026
@SteveSandersonMS SteveSandersonMS added this pull request to the merge queue Jan 20, 2026
Merged via the queue into main with commit a4ffbf0 Jan 20, 2026
22 checks passed
@SteveSandersonMS SteveSandersonMS deleted the stevesa/session-unsubscribe-tests branch January 20, 2026 14:09
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.

3 participants