Pull request 2285: fix-test

Squashed commit of the following:

commit 006391c9c089a2d9fe7ad7157e609898be2ee225
Author: Ainar Garipov <A.Garipov@AdGuard.COM>
Date:   Thu Oct 3 14:15:10 2024 +0300

    dnsforward: imp test more

commit ce743a35ef
Author: Ainar Garipov <A.Garipov@AdGuard.COM>
Date:   Wed Oct 2 21:13:02 2024 +0300

    dnsforward: fix test
This commit is contained in:
Ainar Garipov 2024-10-03 14:56:07 +03:00
parent 355cec1d7b
commit b32b8f9c7e
1 changed files with 7 additions and 5 deletions

View File

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