-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfilter_test.go
61 lines (58 loc) · 1.41 KB
/
filter_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
/*
Copyright © 2019, 2022 M.Watermann, 10247 Berlin, Germany
All rights reserved
EMail : <support@mwat.de>
*/
package sessions
import (
"testing"
)
func TestExcludePaths(t *testing.T) {
soFilterExcludeList = nil // make sure to start with a fresh list
type args struct {
aPath []string
}
x1 := []string{"certs/", "css/", "/favicon", "fonts/"}
l1 := len(x1)
tests := []struct {
name string
args args
want int
}{
// TODO: Add test cases.
{" 1", args{x1}, l1},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := ExcludePaths(tt.args.aPath...); got != tt.want {
t.Errorf("AddExcludePaths() = %v, want %v", got, tt.want)
}
})
}
} // TestExcludePaths()
func Test_excludeURL(t *testing.T) {
soFilterExcludeList = nil // make sure to start with a fresh list
ExcludePaths("css/", "/favicon", "/img/")
type args struct {
aURLpath string
}
tests := []struct {
name string
args args
want bool
}{
// TODO: Add test cases.
{" 1", args{"page.html"}, false},
{" 2", args{"/css/styles.css"}, true},
{" 3", args{"/img/cover.png"}, true},
{" 4", args{"favicon.ico"}, true},
{" 5", args{"/img_cover.png"}, false},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := excludeURL(tt.args.aURLpath); got != tt.want {
t.Errorf("excludeURL() = %v, want %v", got, tt.want)
}
})
}
} // Test_excludeURL()