discovery/consul: fix leaking goroutine from test

Signed-off-by: Mateusz Gozdek <mgozdekof@gmail.com>
pull/9713/head
Mateusz Gozdek 2021-10-21 10:13:09 +02:00 committed by Julien Pivotto
parent d8561dbfd8
commit 0bfef847b0
1 changed files with 5 additions and 1 deletions

View File

@ -307,11 +307,15 @@ func TestNoTargets(t *testing.T) {
ctx, cancel := context.WithCancel(context.Background())
ch := make(chan []*targetgroup.Group)
go d.Run(ctx, ch)
go func() {
d.Run(ctx, ch)
close(ch)
}()
targets := (<-ch)[0].Targets
require.Equal(t, 0, len(targets))
cancel()
<-ch
}
// Watch only the test service.