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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
|
package lib
import (
"testing"
)
func TestConstants(t *testing.T) {
tests := []struct {
name string
got interface{}
expected interface{}
}{
{"ActionAdd", ActionAdd, Action("add")},
{"ActionRemove", ActionRemove, Action("remove")},
{"ActionOutput", ActionOutput, Action("output")},
{"IPv4", IPv4, IPType("ipv4")},
{"IPv6", IPv6, IPType("ipv6")},
{"CaseRemovePrefix", CaseRemovePrefix, CaseRemove(0)},
{"CaseRemoveEntry", CaseRemoveEntry, CaseRemove(1)},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if tt.got != tt.expected {
t.Errorf("got %v, expected %v", tt.got, tt.expected)
}
})
}
}
func TestActionsRegistry(t *testing.T) {
tests := []struct {
action Action
expected bool
}{
{ActionAdd, true},
{ActionRemove, true},
{ActionOutput, true},
{"unknown", false},
}
for _, tt := range tests {
t.Run(string(tt.action), func(t *testing.T) {
got := ActionsRegistry[tt.action]
if got != tt.expected {
t.Errorf("ActionsRegistry[%s] = %v, expected %v", tt.action, got, tt.expected)
}
})
}
}
func TestIgnoreIPv4(t *testing.T) {
result := IgnoreIPv4()
if result != IPv4 {
t.Errorf("IgnoreIPv4() = %v, expected %v", result, IPv4)
}
}
func TestIgnoreIPv6(t *testing.T) {
result := IgnoreIPv6()
if result != IPv6 {
t.Errorf("IgnoreIPv6() = %v, expected %v", result, IPv6)
}
}
|