mirror of
https://github.com/netbirdio/netbird.git
synced 2026-04-18 08:16:39 +00:00
run cancel in defer
This commit is contained in:
@@ -259,6 +259,7 @@ func TestClient_Sync(t *testing.T) {
|
|||||||
ch := make(chan *mgmtProto.SyncResponse, 5)
|
ch := make(chan *mgmtProto.SyncResponse, 5)
|
||||||
|
|
||||||
ctx, cancel := context.WithCancel(context.Background())
|
ctx, cancel := context.WithCancel(context.Background())
|
||||||
|
defer cancel()
|
||||||
go func() {
|
go func() {
|
||||||
err = client.Sync(ctx, info, func(msg *mgmtProto.SyncResponse) error {
|
err = client.Sync(ctx, info, func(msg *mgmtProto.SyncResponse) error {
|
||||||
ch <- msg
|
ch <- msg
|
||||||
@@ -291,7 +292,6 @@ func TestClient_Sync(t *testing.T) {
|
|||||||
t.Error("timeout waiting for test to finish")
|
t.Error("timeout waiting for test to finish")
|
||||||
}
|
}
|
||||||
|
|
||||||
cancel()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func Test_SystemMetaDataFromClient(t *testing.T) {
|
func Test_SystemMetaDataFromClient(t *testing.T) {
|
||||||
|
|||||||
@@ -317,6 +317,7 @@ var _ = Describe("Management service", func() {
|
|||||||
additionalPeers := 10
|
additionalPeers := 10
|
||||||
|
|
||||||
ctx, cancel := context.WithCancel(context.Background())
|
ctx, cancel := context.WithCancel(context.Background())
|
||||||
|
defer cancel()
|
||||||
|
|
||||||
var peers []wgtypes.Key
|
var peers []wgtypes.Key
|
||||||
for i := 0; i < initialPeers; i++ {
|
for i := 0; i < initialPeers; i++ {
|
||||||
@@ -379,7 +380,6 @@ var _ = Describe("Management service", func() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
wg.Wait()
|
wg.Wait()
|
||||||
cancel()
|
|
||||||
|
|
||||||
for _, syncClient := range clients {
|
for _, syncClient := range clients {
|
||||||
err := syncClient.CloseSend()
|
err := syncClient.CloseSend()
|
||||||
|
|||||||
Reference in New Issue
Block a user