dnsforward: imp tests

This commit is contained in:
Stanislav Chzhen 2024-11-22 20:08:28 +03:00
parent 82851aa825
commit 1ca353423c

View file

@ -500,7 +500,10 @@ func TestServerRace(t *testing.T) {
} }
func TestSafeSearch(t *testing.T) { func TestSafeSearch(t *testing.T) {
var upsCalledCounter uint32 var (
upsCalledCounter uint32
wantCNAMECounter uint32
)
safeSearchConf := filtering.SafeSearchConfig{ safeSearchConf := filtering.SafeSearchConfig{
Enabled: true, Enabled: true,
@ -615,6 +618,8 @@ func TestSafeSearch(t *testing.T) {
a := testutil.RequireTypeAssert[*dns.A](t, reply.Answer[1]) a := testutil.RequireTypeAssert[*dns.A](t, reply.Answer[1])
assert.NotEmpty(t, a.A) assert.NotEmpty(t, a.A)
atomic.AddUint32(&wantCNAMECounter, 1)
} else { } else {
require.Len(t, reply.Answer, 1) 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) { 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)
}) })
} }