github.com/jonasnick/go-ethereum@v0.7.12-0.20150216215225-22176f05d387/event/filter/filter_test.go (about) 1 package filter 2 3 import "testing" 4 5 func TestFilters(t *testing.T) { 6 var success bool 7 var failure bool 8 9 fm := New() 10 fm.Start() 11 fm.Install(Generic{ 12 Str1: "hello", 13 Fn: func(data interface{}) { 14 success = data.(bool) 15 }, 16 }) 17 fm.Install(Generic{ 18 Str1: "hello1", 19 Str2: "hello", 20 Fn: func(data interface{}) { 21 failure = true 22 }, 23 }) 24 fm.Notify(Generic{Str1: "hello"}, true) 25 fm.Stop() 26 27 if !success { 28 t.Error("expected 'hello' to be posted") 29 } 30 31 if failure { 32 t.Error("hello1 was triggered") 33 } 34 }