Skip to content

Commit

Permalink
improved tests
Browse files Browse the repository at this point in the history
  • Loading branch information
stanipetrosyan committed Nov 20, 2023
1 parent 6986540 commit 6588f87
Showing 1 changed file with 3 additions and 21 deletions.
24 changes: 3 additions & 21 deletions channel_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ func TestSubscriberHandler(t *testing.T) {
var eventBus = NewEventBus()
var wg sync.WaitGroup

t.Run("should handle a message using channels", func(t *testing.T) {
t.Run("should handle a message", func(t *testing.T) {
wg.Add(1)

eventBus.Channel("my-channel").Subscriber().Listen(func(context Context) {
Expand All @@ -24,7 +24,7 @@ func TestSubscriberHandler(t *testing.T) {
wg.Wait()
})

t.Run("should handle message for more of one handlers", func(t *testing.T) {
t.Run("should handle message with many subscribers", func(t *testing.T) {
wg.Add(2)

eventBus.Channel("newaddress").Subscriber().Listen(func(context Context) {
Expand All @@ -47,7 +47,7 @@ func TestProcessorHandler(t *testing.T) {
var eventBus = NewEventBus()
var wg sync.WaitGroup

t.Run("should pass processor handler", func(t *testing.T) {
t.Run("should pass processor", func(t *testing.T) {
wg.Add(2)

eventBus.Channel("my-channel").Subscriber().Listen(func(context Context) {
Expand All @@ -64,24 +64,6 @@ func TestProcessorHandler(t *testing.T) {
eventBus.Channel("my-channel").Publisher().Publish(message)
wg.Wait()
})

t.Run("should pass message to handler created afted interceptor", func(t *testing.T) {
wg.Add(2)

eventBus.Channel("my-channel").Processor(func(message Message) bool {
wg.Done()
return message.Data == "Hi There"
})

eventBus.Channel("my-channel").Subscriber().Listen(func(context Context) {
assert.Equal(t, "Hi There", context.Result().Data)
wg.Done()
})

message := CreateMessage().SetBody("Hi There")
eventBus.Channel("my-channel").Publisher().Publish(message)
wg.Wait()
})
}

func TestMessageOptions(t *testing.T) {
Expand Down

0 comments on commit 6588f87

Please sign in to comment.