Merge: + dhcpd, clients, dnsfilter: add more tests

#788

* commit '25da23497a19118a22b97d64749fa70337544116':
  + dnsfilter: more tests
  + dhcpd, clients: add more tests
This commit is contained in:
Simon Zolin
2019-07-01 19:26:27 +03:00
3 changed files with 56 additions and 4 deletions

View File

@@ -10,6 +10,7 @@ import (
"testing"
"time"
"github.com/bluele/gcache"
"github.com/miekg/dns"
)
@@ -557,3 +558,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")
}
}