github.com/theQRL/go-zond@v0.1.1/cmd/abigen/namefilter_test.go (about) 1 package main 2 3 import ( 4 "testing" 5 6 "github.com/stretchr/testify/assert" 7 "github.com/stretchr/testify/require" 8 ) 9 10 func TestNameFilter(t *testing.T) { 11 _, err := newNameFilter("Foo") 12 require.Error(t, err) 13 _, err = newNameFilter("too/many:colons:Foo") 14 require.Error(t, err) 15 16 f, err := newNameFilter("a/path:A", "*:B", "c/path:*") 17 require.NoError(t, err) 18 19 for _, tt := range []struct { 20 name string 21 match bool 22 }{ 23 {"a/path:A", true}, 24 {"unknown/path:A", false}, 25 {"a/path:X", false}, 26 {"unknown/path:X", false}, 27 {"any/path:B", true}, 28 {"c/path:X", true}, 29 {"c/path:foo:B", false}, 30 } { 31 match := f.Matches(tt.name) 32 if tt.match { 33 assert.True(t, match, "expected match") 34 } else { 35 assert.False(t, match, "expected no match") 36 } 37 } 38 }