Skip to content

Commit

Permalink
Add test for ExpandTopics
Browse files Browse the repository at this point in the history
  • Loading branch information
gustavosbarreto committed Apr 18, 2017
1 parent a51ef6b commit e8bb2f7
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
6 changes: 3 additions & 3 deletions broker_test.go
Expand Up @@ -11,7 +11,7 @@ import (
)

func TestSubscribe(t *testing.T) {
subscriber, _ := NewSubscriber()
subscriber := NewSubscriber()
subscriber.Topics = []string{"topic"}

broker := NewBroker()
Expand All @@ -30,7 +30,7 @@ func TestSubscribe(t *testing.T) {
func TestUnsubscribe(t *testing.T) {
topic := "topic"

subscriber, _ := NewSubscriber()
subscriber := NewSubscriber()
subscriber.Topics = []string{topic}

broker := NewBroker()
Expand All @@ -44,7 +44,7 @@ func TestPublish(t *testing.T) {
topics := []string{"topic1", "topic2"}
published := []string{}

subscriber, _ := NewSubscriber()
subscriber := NewSubscriber()
subscriber.Topics = topics

monkey.PatchInstanceMethod(reflect.TypeOf(subscriber), "Receiver", func(_ *Subscriber, topic string, payload []byte) {
Expand Down
7 changes: 3 additions & 4 deletions subscriber.go
Expand Up @@ -29,9 +29,8 @@ type SubscriberHooks struct {
OnPublish string `yaml:"OnPublish"`
}

func NewSubscriber() (*Subscriber, error) {
subscriber := &Subscriber{}
return subscriber, nil
func NewSubscriber() *Subscriber {
return &Subscriber{}
}

func (s *Subscriber) Receiver(topic string, payload []byte) {
Expand Down Expand Up @@ -124,7 +123,7 @@ func LoadSubscribers(path string) ([]*Subscriber, error) {
subscribers := []*Subscriber{}

for _, file := range files {
subscriber, _ := NewSubscriber()
subscriber := NewSubscriber()

data, err := ioutil.ReadFile(file)
if err != nil {
Expand Down

0 comments on commit e8bb2f7

Please sign in to comment.