-
Notifications
You must be signed in to change notification settings - Fork 69
/
updater_test.go
34 lines (30 loc) · 829 Bytes
/
updater_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
package main
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestParsing(t *testing.T) {
newBlockCache := &MemoryBlockCache{Backend: make(map[string]bool)}
expected := []string{
"domain1.some",
"domain.with.number",
"domain.2.with.number",
"domain.with.tab",
"domain.with.spaces",
"domain.with.many.spaces",
"domain.with.comment",
"domain.with.number.and.comment",
"domain.with.attached.comment",
"domain.with.number.and.attached.comment",
}
err := parseHostFile("testdata/parser_data.list", newBlockCache)
assert.Nil(t, err)
assert.Equal(t, len(expected), newBlockCache.Length())
for _, host := range expected {
val, err := newBlockCache.Get(host)
assert.Nil(t, err)
if err != nil {
assert.Equalf(t, true, val, "Unexpected blocked state: %v for: %s", val, host)
}
}
}