diff --git a/loader/klconsul/consulloader_test.go b/loader/klconsul/consulloader_test.go index 69a607b9..6acd6b64 100644 --- a/loader/klconsul/consulloader_test.go +++ b/loader/klconsul/consulloader_test.go @@ -237,13 +237,17 @@ func TestLoad(t *testing.T) { var timer = time.NewTimer(150 * time.Millisecond) var watched bool - select { - case <-hl.Watch(): - watched = true - hl.Close() - case <-timer.C: - hl.Close() - require.True(t, watched) + outer: + for { + select { + case <-hl.Watch(): + watched = true + hl.Close() + case <-timer.C: + hl.Close() + require.True(t, watched) + break outer + } } return hl diff --git a/loader/kletcd/etcdloader_test.go b/loader/kletcd/etcdloader_test.go index c758b3c3..1b838dbc 100644 --- a/loader/kletcd/etcdloader_test.go +++ b/loader/kletcd/etcdloader_test.go @@ -227,12 +227,15 @@ func TestEtcdLoader(t *testing.T) { var timer = time.NewTimer(300 * time.Millisecond) var watched bool - select { - case <-timer.C: - l.Close() - require.True(t, watched) - case <-l.Watch(): - watched = true + for { + select { + case <-timer.C: + l.Close() + require.True(t, watched) + return + case <-l.Watch(): + watched = true + } } }, )