mirror of
https://github.com/strukturag/nextcloud-spreed-signaling.git
synced 2023-10-21 07:33:40 -05:00
Use "T.Cleanup()" instead of manually deferred shutdown function.
This commit is contained in:
@@ -48,20 +48,20 @@ func (c *LoopbackNatsClient) waitForSubscriptionsEmpty(ctx context.Context, t *t
|
||||
}
|
||||
}
|
||||
|
||||
func CreateLoopbackNatsClientForTest(t *testing.T) (NatsClient, func()) {
|
||||
func CreateLoopbackNatsClientForTest(t *testing.T) NatsClient {
|
||||
result, err := NewLoopbackNatsClient()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
return result, func() {
|
||||
t.Cleanup(func() {
|
||||
result.Close()
|
||||
}
|
||||
})
|
||||
return result
|
||||
}
|
||||
|
||||
func TestLoopbackNatsClient_Subscribe(t *testing.T) {
|
||||
ensureNoGoroutinesLeak(t, func() {
|
||||
client, shutdown := CreateLoopbackNatsClientForTest(t)
|
||||
defer shutdown()
|
||||
client := CreateLoopbackNatsClientForTest(t)
|
||||
|
||||
testNatsClient_Subscribe(t, client)
|
||||
})
|
||||
@@ -69,8 +69,7 @@ func TestLoopbackNatsClient_Subscribe(t *testing.T) {
|
||||
|
||||
func TestLoopbackClient_PublishAfterClose(t *testing.T) {
|
||||
ensureNoGoroutinesLeak(t, func() {
|
||||
client, shutdown := CreateLoopbackNatsClientForTest(t)
|
||||
defer shutdown()
|
||||
client := CreateLoopbackNatsClientForTest(t)
|
||||
|
||||
testNatsClient_PublishAfterClose(t, client)
|
||||
})
|
||||
@@ -78,8 +77,7 @@ func TestLoopbackClient_PublishAfterClose(t *testing.T) {
|
||||
|
||||
func TestLoopbackClient_SubscribeAfterClose(t *testing.T) {
|
||||
ensureNoGoroutinesLeak(t, func() {
|
||||
client, shutdown := CreateLoopbackNatsClientForTest(t)
|
||||
defer shutdown()
|
||||
client := CreateLoopbackNatsClientForTest(t)
|
||||
|
||||
testNatsClient_SubscribeAfterClose(t, client)
|
||||
})
|
||||
@@ -87,8 +85,7 @@ func TestLoopbackClient_SubscribeAfterClose(t *testing.T) {
|
||||
|
||||
func TestLoopbackClient_BadSubjects(t *testing.T) {
|
||||
ensureNoGoroutinesLeak(t, func() {
|
||||
client, shutdown := CreateLoopbackNatsClientForTest(t)
|
||||
defer shutdown()
|
||||
client := CreateLoopbackNatsClientForTest(t)
|
||||
|
||||
testNatsClient_BadSubjects(t, client)
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user