4 "github.com/revel/revel"
5 "github.com/stretchr/testify/assert"
9 // Test that the event handler can be attached and it dispatches the event received
10 func TestEventHandler(t *testing.T) {
12 newListener := func(typeOf revel.Event, value interface{}) (responseOf revel.EventResponse) {
13 if typeOf == revel.REVEL_FAILURE {
18 // Attach the same handlder twice so we expect to see the response twice as well
19 revel.AddInitEventHandler(newListener)
20 revel.AddInitEventHandler(newListener)
21 revel.RaiseEvent(revel.REVEL_AFTER_MODULES_LOADED, nil)
22 revel.RaiseEvent(revel.REVEL_FAILURE, nil)
23 assert.Equal(t, counter, 2, "Expected event handler to have been called")