+ dnsfilter: more tests

This commit is contained in:
Simon Zolin 2019-06-26 18:13:09 +03:00
parent efaaeb58eb
commit 25da23497a
1 changed files with 15 additions and 0 deletions

View File

@ -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")
}
}