-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathengine_test.go
44 lines (38 loc) · 808 Bytes
/
engine_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
35
36
37
38
39
40
41
42
43
44
package policy
import (
"context"
"testing"
"github.com/AdguardTeam/urlfilter"
"github.com/AdguardTeam/urlfilter/filterlist"
"github.com/miekg/dns"
"github.com/stretchr/testify/assert"
)
func TestEngine_Match(t *testing.T) {
list1 := &filterlist.StringRuleList{
ID: 1,
RulesText: "||example.org\n",
IgnoreCosmetic: false,
}
rules := []filterlist.RuleList{
list1,
}
storage, err := filterlist.NewRuleStorage(rules)
assert.NoError(t, err)
e := urlfilter.NewNetworkEngine(storage)
ctx := context.Background()
engine := &Engine{
ctx: ctx,
engine: e,
}
// Create a DNS message for testing
msg := &dns.Msg{
Question: []dns.Question{
{
Name: "example.org.",
Qtype: dns.TypeA,
},
},
}
result := engine.Match(msg)
assert.True(t, result)
}