Run function to test for goroutine leaks as subtest.

This makes sure the test has been completely teared down before the
goroutines are counted and thus should prevent flaky failed tests.
This commit is contained in:
Joachim Bauch
2023-01-17 14:51:02 +01:00
parent 5a12959821
commit 0020076f2b
3 changed files with 30 additions and 11 deletions
+4 -4
View File
@@ -60,7 +60,7 @@ func CreateLoopbackNatsClientForTest(t *testing.T) NatsClient {
}
func TestLoopbackNatsClient_Subscribe(t *testing.T) {
ensureNoGoroutinesLeak(t, func() {
ensureNoGoroutinesLeak(t, func(t *testing.T) {
client := CreateLoopbackNatsClientForTest(t)
testNatsClient_Subscribe(t, client)
@@ -68,7 +68,7 @@ func TestLoopbackNatsClient_Subscribe(t *testing.T) {
}
func TestLoopbackClient_PublishAfterClose(t *testing.T) {
ensureNoGoroutinesLeak(t, func() {
ensureNoGoroutinesLeak(t, func(t *testing.T) {
client := CreateLoopbackNatsClientForTest(t)
testNatsClient_PublishAfterClose(t, client)
@@ -76,7 +76,7 @@ func TestLoopbackClient_PublishAfterClose(t *testing.T) {
}
func TestLoopbackClient_SubscribeAfterClose(t *testing.T) {
ensureNoGoroutinesLeak(t, func() {
ensureNoGoroutinesLeak(t, func(t *testing.T) {
client := CreateLoopbackNatsClientForTest(t)
testNatsClient_SubscribeAfterClose(t, client)
@@ -84,7 +84,7 @@ func TestLoopbackClient_SubscribeAfterClose(t *testing.T) {
}
func TestLoopbackClient_BadSubjects(t *testing.T) {
ensureNoGoroutinesLeak(t, func() {
ensureNoGoroutinesLeak(t, func(t *testing.T) {
client := CreateLoopbackNatsClientForTest(t)
testNatsClient_BadSubjects(t, client)