summaryrefslogtreecommitdiff
path: root/events/events_test.go
blob: 6c5013923cb6bce2229cc2f247924e27a598b445 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
package events

import (
	"testing"

	"github.com/stretchr/testify/require"
)

func TestEvenHandler(t *testing.T) {
	eh, id := Bus()

	ch := make(chan Event, 100)
	err := eh.SubscribeP(id, "http.EventJobOK", ch)
	require.NoError(t, err)

	eh.Send(NewRREvent(EventJobOK, "foo", "http"))

	evt := <-ch
	require.Equal(t, "foo", evt.Message())
	require.Equal(t, "http", evt.Plugin())
	require.Equal(t, "EventJobOK", evt.Type().String())
}