Task mentions (#926)
Co-authored-by: kolaente <k@knt.li> Reviewed-on: https://kolaente.dev/vikunja/api/pulls/926 Co-authored-by: konrad <konrad@kola-entertainments.de> Co-committed-by: konrad <konrad@kola-entertainments.de>
This commit is contained in:
@ -17,8 +17,12 @@
|
||||
package events
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"testing"
|
||||
|
||||
"github.com/ThreeDotsLabs/watermill"
|
||||
"github.com/ThreeDotsLabs/watermill/message"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
@ -47,3 +51,13 @@ func AssertDispatched(t *testing.T, event Event) {
|
||||
|
||||
assert.True(t, found, "Failed to assert "+event.Name()+" has been dispatched.")
|
||||
}
|
||||
|
||||
// TestListener takes an event and a listener and calls the listener's Handle method.
|
||||
func TestListener(t *testing.T, event Event, listener Listener) {
|
||||
content, err := json.Marshal(event)
|
||||
assert.NoError(t, err)
|
||||
|
||||
msg := message.NewMessage(watermill.NewUUID(), content)
|
||||
err = listener.Handle(msg)
|
||||
assert.NoError(t, err)
|
||||
}
|
||||
|
Reference in New Issue
Block a user