Fix race in safesearch tests

This commit is contained in:
Andrey Meshkov
2019-02-25 18:56:51 +03:00
parent 77348e746f
commit c71d6ed433
4 changed files with 26 additions and 12 deletions

View File

@@ -654,13 +654,19 @@ func TestCheckHostSafeSearchGoogle(t *testing.T) {
}
}
func TestSafeSearchCacheYandex (t *testing.T) {
func TestSafeSearchCacheYandex(t *testing.T) {
d := NewForTest()
defer d.Destroy()
domain := "yandex.ru"
var result Result
var err error
// Check host with disabled safesearch
result, err := d.CheckHost(domain)
result, err = d.CheckHost(domain)
if err != nil {
t.Fatalf("Cannot check host due to %s", err)
}
if result.IP != nil {
t.Fatalf("SafeSearch is not enabled but there is an answer for `%s` !", domain)
}
@@ -693,11 +699,14 @@ func TestSafeSearchCacheYandex (t *testing.T) {
}
}
func TestSafeSearchCacheGoogle (t *testing.T) {
func TestSafeSearchCacheGoogle(t *testing.T) {
d := NewForTest()
defer d.Destroy()
domain := "www.google.ru"
result, err := d.CheckHost(domain)
if err != nil {
t.Fatalf("Cannot check host due to %s", err)
}
if result.IP != nil {
t.Fatalf("SafeSearch is not enabled but there is an answer!")
}

View File

@@ -1,11 +1,11 @@
package dnsfilter
var safeSearchDomains = map[string]string{
"yandex.com": "213.180.193.56",
"yandex.ru": "213.180.193.56",
"yandex.ua": "213.180.193.56",
"yandex.by": "213.180.193.56",
"yandex.kz": "213.180.193.56",
"yandex.com": "213.180.193.56",
"yandex.ru": "213.180.193.56",
"yandex.ua": "213.180.193.56",
"yandex.by": "213.180.193.56",
"yandex.kz": "213.180.193.56",
"www.yandex.com": "213.180.193.56",
"www.yandex.ru": "213.180.193.56",
"www.yandex.ua": "213.180.193.56",