-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathverbosity_filter_test.go
34 lines (25 loc) · 2.09 KB
/
verbosity_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
package tlog
import (
"testing"
"github.com/nikandfor/assert"
)
func TestVerbosity(t *testing.T) {
assert.True(t, (&filter{f: "topic"}).matchPattern("path/to/pkg.Func", "path/to/pkg/file.go", "topic"))
assert.True(t, (&filter{f: "topic,topic_a"}).matchPattern("path/to/pkg.Func", "path/to/pkg/file.go", "topic"))
assert.True(t, (&filter{f: "topic+topic_a"}).matchPattern("path/to/pkg.Func", "path/to/pkg/file.go", "topic"))
assert.True(t, (&filter{f: "=topic"}).matchPattern("path/to/pkg.Func", "path/to/pkg/file.go", "topic"))
assert.True(t, (&filter{f: "pkg=topic"}).matchPattern("path/to/pkg.Func", "path/to/pkg/file.go", "topic"))
assert.True(t, (&filter{f: "pkg=*"}).matchPattern("path/to/pkg.Func", "path/to/pkg/file.go", "topic"))
assert.True(t, (&filter{f: "Func=topic"}).matchPattern("path/to/pkg.Func", "path/to/pkg/file.go", "topic"))
assert.True(t, (&filter{f: "Type=topic"}).matchPattern("path/to/pkg.Type.Func", "path/to/pkg/file.go", "topic"))
assert.True(t, (&filter{f: "Type=topic"}).matchPattern("path/to/pkg.(*Type).Func", "path/to/pkg/file.go", "topic"))
assert.True(t, (&filter{f: "pkg.Type.Func=topic"}).matchPattern("path/to/pkg.(*Type).Func", "path/to/pkg/file.go", "topic"))
assert.True(t, (&filter{f: "pkg.(*Type).Func=topic"}).matchPattern("path/to/pkg.(*Type).Func", "path/to/pkg/file.go", "topic"))
assert.True(t, (&filter{f: "pkg.(Type).Func=topic"}).matchPattern("path/to/pkg.(*Type).Func", "path/to/pkg/file.go", "topic"))
assert.True(t, (&filter{f: "file.go=topic"}).matchPattern("path/to/pkg.Func", "path/to/pkg/file.go", "topic"))
assert.True(t, (&filter{f: "pkg/file.go=topic"}).matchPattern("path/to/pkg.Func", "path/to/pkg/file.go", "topic"))
assert.False(t, (&filter{f: "topic_a,topic_b"}).matchPattern("path/to/pkg.Func", "path/to/pkg/file.go", "topic"))
assert.False(t, (&filter{f: "pkg"}).matchPattern("path/to/pkg.Func", "path/to/pkg/file.go", "topic"))
assert.False(t, (&filter{f: "file.go"}).matchPattern("path/to/pkg.Func", "path/to/pkg/file.go", "topic"))
assert.False(t, (&filter{f: "Func"}).matchPattern("path/to/pkg.Func", "path/to/pkg/file.go", "topic"))
}