diff --git a/discovery/legacymanager/manager_test.go b/discovery/legacymanager/manager_test.go index ce2278d23..57c82b72a 100644 --- a/discovery/legacymanager/manager_test.go +++ b/discovery/legacymanager/manager_test.go @@ -668,13 +668,16 @@ func TestTargetUpdatesOrder(t *testing.T) { discoveryManager.updatert = 100 * time.Millisecond var totalUpdatesCount int - provUpdates := make(chan []*targetgroup.Group) for _, up := range tc.updates { - go newMockDiscoveryProvider(up...).Run(ctx, provUpdates) if len(up) > 0 { totalUpdatesCount += len(up) } } + provUpdates := make(chan []*targetgroup.Group, totalUpdatesCount) + + for _, up := range tc.updates { + go newMockDiscoveryProvider(up...).Run(ctx, provUpdates) + } for x := 0; x < totalUpdatesCount; x++ { select { diff --git a/discovery/manager_test.go b/discovery/manager_test.go index 80ea1008e..970168b0f 100644 --- a/discovery/manager_test.go +++ b/discovery/manager_test.go @@ -668,13 +668,16 @@ func TestTargetUpdatesOrder(t *testing.T) { discoveryManager.updatert = 100 * time.Millisecond var totalUpdatesCount int - provUpdates := make(chan []*targetgroup.Group) for _, up := range tc.updates { - go newMockDiscoveryProvider(up...).Run(ctx, provUpdates) if len(up) > 0 { totalUpdatesCount += len(up) } } + provUpdates := make(chan []*targetgroup.Group, totalUpdatesCount) + + for _, up := range tc.updates { + go newMockDiscoveryProvider(up...).Run(ctx, provUpdates) + } for x := 0; x < totalUpdatesCount; x++ { select {