From 25da23497a19118a22b97d64749fa70337544116 Mon Sep 17 00:00:00 2001 From: Simon Zolin Date: Wed, 26 Jun 2019 18:13:09 +0300 Subject: [PATCH] + dnsfilter: more tests --- dnsfilter/dnsfilter_test.go | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/dnsfilter/dnsfilter_test.go b/dnsfilter/dnsfilter_test.go index 00324471..27d203bb 100644 --- a/dnsfilter/dnsfilter_test.go +++ b/dnsfilter/dnsfilter_test.go @@ -10,6 +10,7 @@ import ( "testing" "time" + "github.com/bluele/gcache" "github.com/miekg/dns" ) @@ -572,3 +573,17 @@ func BenchmarkSafeSearchParallel(b *testing.B) { } }) } + +func TestDnsfilterDialCache(t *testing.T) { + d := Dnsfilter{} + dialCache = gcache.New(1).LRU().Expiration(30 * time.Minute).Build() + + d.shouldBeInDialCache("hostname") + if searchInDialCache("hostname") != "" { + t.Errorf("searchInDialCache") + } + addToDialCache("hostname", "1.1.1.1") + if searchInDialCache("hostname") != "1.1.1.1" { + t.Errorf("searchInDialCache") + } +}