github.com/lonnblad/godog@v0.7.14-0.20200306004719-1b0cb3259847/tag_filter_test.go (about) 1 package godog 2 3 import ( 4 "testing" 5 6 "github.com/cucumber/messages-go/v9" 7 ) 8 9 func assertNotMatchesTagFilter(tags []*messages.Pickle_PickleTag, filter string, t *testing.T) { 10 if matchesTags(filter, tags) { 11 t.Errorf(`expected tags: %v not to match tag filter "%s", but it did`, tags, filter) 12 } 13 } 14 15 func assertMatchesTagFilter(tags []*messages.Pickle_PickleTag, filter string, t *testing.T) { 16 if !matchesTags(filter, tags) { 17 t.Errorf(`expected tags: %v to match tag filter "%s", but it did not`, tags, filter) 18 } 19 } 20 21 func TestTagFilter(t *testing.T) { 22 assertMatchesTagFilter([]*tag{{Name: "wip"}}, "@wip", t) 23 assertMatchesTagFilter([]*tag{}, "~@wip", t) 24 assertMatchesTagFilter([]*tag{{Name: "one"}, {Name: "two"}}, "@two,@three", t) 25 assertMatchesTagFilter([]*tag{{Name: "one"}, {Name: "two"}}, "@one&&@two", t) 26 assertMatchesTagFilter([]*tag{{Name: "one"}, {Name: "two"}}, "one && two", t) 27 28 assertNotMatchesTagFilter([]*tag{}, "@wip", t) 29 assertNotMatchesTagFilter([]*tag{{Name: "one"}, {Name: "two"}}, "@one&&~@two", t) 30 assertNotMatchesTagFilter([]*tag{{Name: "one"}, {Name: "two"}}, "@one && ~@two", t) 31 } 32 33 type tag = messages.Pickle_PickleTag