run cancel in defer

This commit is contained in:
Pascal Fischer
2025-01-17 01:11:09 +01:00
parent eeb688cb5e
commit aa34dda05a
2 changed files with 2 additions and 2 deletions

View File

@@ -259,6 +259,7 @@ func TestClient_Sync(t *testing.T) {
ch := make(chan *mgmtProto.SyncResponse, 5)
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
go func() {
err = client.Sync(ctx, info, func(msg *mgmtProto.SyncResponse) error {
ch <- msg
@@ -291,7 +292,6 @@ func TestClient_Sync(t *testing.T) {
t.Error("timeout waiting for test to finish")
}
cancel()
}
func Test_SystemMetaDataFromClient(t *testing.T) {

View File

@@ -317,6 +317,7 @@ var _ = Describe("Management service", func() {
additionalPeers := 10
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
var peers []wgtypes.Key
for i := 0; i < initialPeers; i++ {
@@ -379,7 +380,6 @@ var _ = Describe("Management service", func() {
}
wg.Wait()
cancel()
for _, syncClient := range clients {
err := syncClient.CloseSend()