Skip to content

test(amqp091): join connectionWatcher goroutines in test teardown#109

Merged
bithckr merged 2 commits into
miotte-pr7from
miotte-pr9
Jun 10, 2026
Merged

test(amqp091): join connectionWatcher goroutines in test teardown#109
bithckr merged 2 commits into
miotte-pr7from
miotte-pr9

Conversation

@miotte

@miotte miotte commented May 30, 2026

Copy link
Copy Markdown
Contributor

Fixes #108

Add a sync.WaitGroup to BrokerDetails so the connectionWatcher goroutine started by Connect is joinable, plus a stopWatcher test helper deferred in every Connect-based test so a watcher can no longer outlive its test and race the NewAmqpConn091 swap or panic on a stale mock.

Stacked on #102; retarget to main once it merges.

Add a sync.WaitGroup to BrokerDetails so the connectionWatcher goroutine
started by Connect is joinable, and a stopWatcher test helper that
disconnects a client and waits for its watcher to exit. Defer it in every
Connect-based test so a watcher can no longer outlive its test and either
race the package-level NewAmqpConn091 swap (read in connect()) or panic
calling IsClosed() on a stale mock from its 30s fallback branch.

Signed-off-by: Michael Otteni <MichaelGOtteni@gmail.com>
Comment thread internal/provider/connectors/amqp091/amqp091_test.go Outdated
Follow Go convention of passing context.Context as the first parameter.
Reorders the stopWatcher signature and updates all call sites.

Signed-off-by: Michael Otteni <MichaelGOtteni@gmail.com>
@rsperl

rsperl commented Jun 1, 2026

Copy link
Copy Markdown
Contributor

@miotte - Looks great. Could you move whatever is necessary in the PR description to the ticket instead? To keep the changelog manageable, we'd like for the PR desc to just be a couple of lines max.

@miotte

miotte commented Jun 1, 2026

Copy link
Copy Markdown
Contributor Author

@rsperl Do the commit message bodies need to be pruned as well?

@bithckr
bithckr merged commit d9468c6 into miotte-pr7 Jun 10, 2026
1 check passed
@bithckr
bithckr deleted the miotte-pr9 branch June 10, 2026 11:40
miotte added a commit that referenced this pull request Jun 10, 2026
* test(amqp091): join connectionWatcher goroutines in teardown

Add a sync.WaitGroup to BrokerDetails so the connectionWatcher goroutine
started by Connect is joinable, and a stopWatcher test helper that
disconnects a client and waits for its watcher to exit. Defer it in every
Connect-based test so a watcher can no longer outlive its test and either
race the package-level NewAmqpConn091 swap (read in connect()) or panic
calling IsClosed() on a stale mock from its 30s fallback branch.

---------

Signed-off-by: Michael Otteni <MichaelGOtteni@gmail.com>
miotte added a commit that referenced this pull request Jun 10, 2026
The stopWatcher teardown line added in #109 pushed the near-identical
Test_ClientExists/Test_ClientExists_false pair over golangci-lint's dupl
threshold. Collapse them into one table-driven test so the shared setup
lives in a single place.

Signed-off-by: Michael Otteni <MichaelGOtteni@gmail.com>
miotte added a commit that referenced this pull request Jun 10, 2026
* test(amqp091): join connectionWatcher goroutines in teardown

Add a sync.WaitGroup to BrokerDetails so the connectionWatcher goroutine
started by Connect is joinable, and a stopWatcher test helper that
disconnects a client and waits for its watcher to exit. Defer it in every
Connect-based test so a watcher can no longer outlive its test and either
race the package-level NewAmqpConn091 swap (read in connect()) or panic
calling IsClosed() on a stale mock from its 30s fallback branch.

---------

Signed-off-by: Michael Otteni <MichaelGOtteni@gmail.com>
miotte added a commit that referenced this pull request Jun 10, 2026
The stopWatcher teardown line added in #109 pushed the near-identical
Test_ClientExists/Test_ClientExists_false pair over golangci-lint's dupl
threshold. Collapse them into one table-driven test so the shared setup
lives in a single place.

Signed-off-by: Michael Otteni <MichaelGOtteni@gmail.com>
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