From b32b8f9c7eabb601d5ea120fdeb5400d8068a023 Mon Sep 17 00:00:00 2001 From: Ainar Garipov Date: Thu, 3 Oct 2024 14:56:07 +0300 Subject: [PATCH] Pull request 2285: fix-test Squashed commit of the following: commit 006391c9c089a2d9fe7ad7157e609898be2ee225 Author: Ainar Garipov Date: Thu Oct 3 14:15:10 2024 +0300 dnsforward: imp test more commit ce743a35eff5271cb13a892373536ae815a74ebb Author: Ainar Garipov Date: Wed Oct 2 21:13:02 2024 +0300 dnsforward: fix test --- internal/dnsforward/dnsforward_test.go | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) 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)