Skip to content

Commit

Permalink
fixed several test cases failing
Browse files Browse the repository at this point in the history
fixed several test cases failing
  • Loading branch information
werbenhu committed Apr 25, 2023
1 parent a561291 commit 7aedfe0
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
1 change: 0 additions & 1 deletion eventbus.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ func (c *channel) loop() {
payload = reflect.ValueOf(param)
}

payload = reflect.ValueOf(param)
(*handler).Call([]reflect.Value{topic, payload})
return true
})
Expand Down
7 changes: 5 additions & 2 deletions eventbus_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package eventbus
import (
"sync"
"testing"
"time"

"github.com/stretchr/testify/assert"
)
Expand Down Expand Up @@ -89,7 +90,6 @@ func Test_channelPublish(t *testing.T) {
assert.NotNil(t, ch)
assert.NotNil(t, ch.channel)
assert.Equal(t, "test_topic", ch.topic)

ch.subscribe(busHandlerOne)

var wg sync.WaitGroup
Expand All @@ -104,8 +104,11 @@ func Test_channelPublish(t *testing.T) {
}()
wg.Wait()

err := ch.publish(nil)
assert.Nil(t, err)
time.Sleep(time.Millisecond)
ch.close()
err := ch.publish(1)
err = ch.publish(1)
assert.Equal(t, ErrChannelClosed, err)
}

Expand Down
8 changes: 8 additions & 0 deletions pipe_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,14 @@ func Test_NewBufferedPipe(t *testing.T) {
assert.NotNil(t, p.stopCh)
assert.NotNil(t, p.handlers)
p.Close()

pipeZero := NewBufferedPipe[int](0)
assert.NotNil(t, pipeZero)
assert.NotNil(t, pipeZero.channel)
assert.Equal(t, 1, cap(pipeZero.channel))
assert.NotNil(t, pipeZero.stopCh)
assert.NotNil(t, pipeZero.handlers)
pipeZero.Close()
}

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

0 comments on commit 7aedfe0

Please sign in to comment.