Browse Source

undeprecate subscriber, add test for dispatcher

pull/104/head v0.12.0
wagslane 3 years ago
parent
commit
98bbc9c484
3 changed files with 37 additions and 5 deletions
  1. +0
    -3
      internal/channelmanager/safe_wraps.go
  2. +37
    -0
      internal/dispatcher/dispatcher_test.go
  3. +0
    -2
      publish.go

+ 0
- 3
internal/channelmanager/safe_wraps.go View File

@ -137,8 +137,6 @@ func (chanManager *ChannelManager) QosSafe(
/*
PublishSafe safely wraps the (*amqp.Channel).Publish method.
Deprecated: Use PublishWithContextSafe instead.
*/
func (chanManager *ChannelManager) PublishSafe(
exchange string, key string, mandatory bool, immediate bool, msg amqp.Publishing,
@ -155,7 +153,6 @@ func (chanManager *ChannelManager) PublishSafe(
)
}
// PublishWithContextSafe safely wraps the (*amqp.Channel).PublishWithContext method.
func (chanManager *ChannelManager) PublishWithContextSafe(
ctx context.Context, exchange string, key string, mandatory bool, immediate bool, msg amqp.Publishing,


+ 37
- 0
internal/dispatcher/dispatcher_test.go View File

@ -0,0 +1,37 @@
package dispatcher
import (
"testing"
"time"
)
func TestNewDispatcher(t *testing.T) {
d := NewDispatcher()
if d == nil {
t.Error("Dispatcher is nil")
}
if d.subscribers == nil {
t.Error("Dispatcher subscribers is nil")
}
if d.subscribersMux == nil {
t.Error("Dispatcher subscribersMux is nil")
}
}
func TestAddSubscriber(t *testing.T) {
d := NewDispatcher()
d.AddSubscriber()
if len(d.subscribers) != 1 {
t.Error("Dispatcher subscribers length is not 1")
}
}
func TestCloseSubscriber(t *testing.T) {
d := NewDispatcher()
_, closeCh := d.AddSubscriber()
close(closeCh)
time.Sleep(time.Millisecond)
if len(d.subscribers) != 0 {
t.Error("Dispatcher subscribers length is not 0")
}
}

+ 0
- 2
publish.go View File

@ -132,8 +132,6 @@ func (publisher *Publisher) handleRestarts() {
/*
Publish publishes the provided data to the given routing keys over the connection.
Deprecated: Use PublishWithContext instead.
*/
func (publisher *Publisher) Publish(
data []byte,


Loading…
Cancel
Save