diff --git a/internal/dnsforward/dnsforward_test.go b/internal/dnsforward/dnsforward_test.go index f56e90df..25565503 100644 --- a/internal/dnsforward/dnsforward_test.go +++ b/internal/dnsforward/dnsforward_test.go @@ -583,13 +583,15 @@ func TestSafeSearch(t *testing.T) { t.Run(tc.host, func(t *testing.T) { req := createTestMessage(tc.host) + // TODO(a.garipov): Create our own helper for this. var reply *dns.Msg - require.Eventually(t, func() (ok bool) { - reply, _, err = client.Exchange(req, addr) - - return err == nil + once := &sync.Once{} + require.EventuallyWithT(t, func(c *assert.CollectT) { + r, _, errExch := client.Exchange(req, addr) + if assert.NoError(c, errExch) { + once.Do(func() { reply = r }) + } }, testTimeout*10, testTimeout) - require.NoErrorf(t, err, "couldn't talk to server %s: %s", addr, err) if tc.wantCNAME != "" { require.Len(t, reply.Answer, 2)