-
Notifications
You must be signed in to change notification settings - Fork 1
/
measurements_test.go
67 lines (59 loc) · 1.46 KB
/
measurements_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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
/*
(C) 2022 Robert Kisteleki & RIPE NCC
See LICENSE file for the license.
*/
package goat
import (
"testing"
)
// Test if the filter validator does a decent job
func TestMeasurementFilterValidator(t *testing.T) {
var err error
var filter MeasurementFilter
badtag := "*"
goodtag := "ooo"
filter = NewMeasurementFilter()
filter.FilterTags([]string{badtag})
err = filter.verifyFilters()
if err == nil {
t.Errorf("Bad tag '%s' not filtered properly", badtag)
}
filter = NewMeasurementFilter()
filter.FilterTags([]string{"ooo"})
err = filter.verifyFilters()
if err != nil {
t.Errorf("Good tag '%s' is not allowed", goodtag)
}
filter = NewMeasurementFilter()
filter.FilterAddressFamily(5)
err = filter.verifyFilters()
if err == nil {
t.Error("Bad 5 af allowed")
}
filter = NewMeasurementFilter()
filter.FilterAddressFamily(4)
err = filter.verifyFilters()
if err != nil {
t.Error("Good af 4 is not allowed")
}
badproto := "sctp"
goodproto := "udp"
filter = NewMeasurementFilter()
filter.FilterProtocol(badproto)
err = filter.verifyFilters()
if err == nil {
t.Errorf("Bad protocol '%s' not filtered properly", badtag)
}
filter = NewMeasurementFilter()
filter.FilterProtocol(goodproto)
err = filter.verifyFilters()
if err != nil {
t.Errorf("Good protocol '%s' is not allowed", goodtag)
}
filter = NewMeasurementFilter()
filter.Sort("abcd")
err = filter.verifyFilters()
if err == nil {
t.Error("Sort order is not filtered properly")
}
}