From 1ca353423ca4dcc7616475fbf12c9b5b9450a5ea Mon Sep 17 00:00:00 2001 From: Stanislav Chzhen Date: Fri, 22 Nov 2024 20:08:28 +0300 Subject: [PATCH] dnsforward: imp tests --- internal/dnsforward/dnsforward_test.go | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/internal/dnsforward/dnsforward_test.go b/internal/dnsforward/dnsforward_test.go index 11275188..fb642045 100644 --- a/internal/dnsforward/dnsforward_test.go +++ b/internal/dnsforward/dnsforward_test.go @@ -500,7 +500,10 @@ func TestServerRace(t *testing.T) { } func TestSafeSearch(t *testing.T) { - var upsCalledCounter uint32 + var ( + upsCalledCounter uint32 + wantCNAMECounter uint32 + ) safeSearchConf := filtering.SafeSearchConfig{ Enabled: true, @@ -615,6 +618,8 @@ func TestSafeSearch(t *testing.T) { a := testutil.RequireTypeAssert[*dns.A](t, reply.Answer[1]) assert.NotEmpty(t, a.A) + + atomic.AddUint32(&wantCNAMECounter, 1) } else { require.Len(t, reply.Answer, 1) @@ -625,7 +630,10 @@ func TestSafeSearch(t *testing.T) { } t.Run("mock_upstream_is_used", func(t *testing.T) { - assert.Positive(t, atomic.LoadUint32(&upsCalledCounter)) + called := atomic.LoadUint32(&upsCalledCounter) + want := atomic.LoadUint32(&wantCNAMECounter) + + assert.Equal(t, want, called) }) }