tlog.app/go/tlog@v0.23.1/verbosity_filter_test.go (about)

     1  package tlog
     2  
     3  import (
     4  	"testing"
     5  
     6  	"github.com/nikandfor/assert"
     7  )
     8  
     9  func TestVerbosity(t *testing.T) {
    10  	assert.True(t, (&filter{f: "topic"}).matchPattern("path/to/pkg.Func", "path/to/pkg/file.go", "topic"))
    11  	assert.True(t, (&filter{f: "topic,topic_a"}).matchPattern("path/to/pkg.Func", "path/to/pkg/file.go", "topic"))
    12  	assert.True(t, (&filter{f: "topic+topic_a"}).matchPattern("path/to/pkg.Func", "path/to/pkg/file.go", "topic"))
    13  
    14  	assert.True(t, (&filter{f: "=topic"}).matchPattern("path/to/pkg.Func", "path/to/pkg/file.go", "topic"))
    15  
    16  	assert.True(t, (&filter{f: "pkg=topic"}).matchPattern("path/to/pkg.Func", "path/to/pkg/file.go", "topic"))
    17  	assert.True(t, (&filter{f: "pkg=*"}).matchPattern("path/to/pkg.Func", "path/to/pkg/file.go", "topic"))
    18  
    19  	assert.True(t, (&filter{f: "Func=topic"}).matchPattern("path/to/pkg.Func", "path/to/pkg/file.go", "topic"))
    20  
    21  	assert.True(t, (&filter{f: "Type=topic"}).matchPattern("path/to/pkg.Type.Func", "path/to/pkg/file.go", "topic"))
    22  	assert.True(t, (&filter{f: "Type=topic"}).matchPattern("path/to/pkg.(*Type).Func", "path/to/pkg/file.go", "topic"))
    23  	assert.True(t, (&filter{f: "pkg.Type.Func=topic"}).matchPattern("path/to/pkg.(*Type).Func", "path/to/pkg/file.go", "topic"))
    24  	assert.True(t, (&filter{f: "pkg.(*Type).Func=topic"}).matchPattern("path/to/pkg.(*Type).Func", "path/to/pkg/file.go", "topic"))
    25  	assert.True(t, (&filter{f: "pkg.(Type).Func=topic"}).matchPattern("path/to/pkg.(*Type).Func", "path/to/pkg/file.go", "topic"))
    26  
    27  	assert.True(t, (&filter{f: "file.go=topic"}).matchPattern("path/to/pkg.Func", "path/to/pkg/file.go", "topic"))
    28  	assert.True(t, (&filter{f: "pkg/file.go=topic"}).matchPattern("path/to/pkg.Func", "path/to/pkg/file.go", "topic"))
    29  
    30  	assert.False(t, (&filter{f: "topic_a,topic_b"}).matchPattern("path/to/pkg.Func", "path/to/pkg/file.go", "topic"))
    31  	assert.False(t, (&filter{f: "pkg"}).matchPattern("path/to/pkg.Func", "path/to/pkg/file.go", "topic"))
    32  	assert.False(t, (&filter{f: "file.go"}).matchPattern("path/to/pkg.Func", "path/to/pkg/file.go", "topic"))
    33  	assert.False(t, (&filter{f: "Func"}).matchPattern("path/to/pkg.Func", "path/to/pkg/file.go", "topic"))
    34  }