Skip to content

Commit

Permalink
add some basic tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mreiferson committed Nov 5, 2014
1 parent ebdf26c commit 5ee66d2
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion consumer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ func consumerTest(t *testing.T, cb func(c *Config)) {
}
topicName = topicName + strconv.Itoa(int(time.Now().Unix()))
q, _ := NewConsumer(topicName, "ch", config)
q.SetLogger(nullLogger, LogLevelInfo)
// q.SetLogger(nullLogger, LogLevelInfo)

h := &MyTestHandler{
t: t,
Expand All @@ -182,6 +182,21 @@ func consumerTest(t *testing.T, cb func(c *Config)) {
t.Fatal("should not be able to connect to the same NSQ twice")
}

err = q.DisconnectFromNSQD("1.2.3.4:4150")
if err == nil {
t.Fatal("should not be able to disconnect from an unknown nsqd")
}

err = q.ConnectToNSQD("1.2.3.4:4150")
if err == nil {
t.Fatal("should not be able to connect to non-existent nsqd")
}

err = q.DisconnectFromNSQD("1.2.3.4:4150")
if err != nil {
t.Fatal("should be able to disconnect from an nsqd - " + err.Error())
}

<-q.StopChan

if h.messagesReceived != 8 || h.messagesSent != 4 {
Expand Down

0 comments on commit 5ee66d2

Please sign in to comment.