Skip to content

Commit

Permalink
Add time.Sleep after subscribe to topic
Browse files Browse the repository at this point in the history
Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com>
  • Loading branch information
darkodraskovic committed Jun 18, 2020
1 parent f2e4418 commit e1b60db
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
5 changes: 4 additions & 1 deletion pkg/messaging/mqtt/pubsub_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ package mqtt_test
import (
"fmt"
"testing"
"time"

"github.com/golang/protobuf/proto"
"github.com/mainflux/mainflux/pkg/messaging"
Expand All @@ -24,9 +25,10 @@ var (
msgChan = make(chan messaging.Message)
)

func TestSubscribe(t *testing.T) {
func TestPubsub(t *testing.T) {
err := subscriber.Subscribe(topic, handler)
require.Nil(t, err, fmt.Sprintf("got unexpected error: %s", err))
time.Sleep(time.Second * 10)

cases := []struct {
desc string
Expand Down Expand Up @@ -69,6 +71,7 @@ func TestSubscribe(t *testing.T) {
require.Nil(t, err, fmt.Sprintf("got unexpected error: %s", err))

receivedMsg := <-msgChan
// _ = receivedMsg
assert.Equal(t, expectedMsg, receivedMsg, fmt.Sprintf("%s: expected %+v got %+v\n", tc.desc, expectedMsg, receivedMsg))
}
}
Expand Down
1 change: 0 additions & 1 deletion pkg/messaging/mqtt/setup_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ func TestMain(m *testing.M) {
log.Fatalf("Could not start container: %s", err)
}
log.Println("VerneMQ container created")

handleInterrupt(pool, container)

address := fmt.Sprintf("%s:%s", "localhost", container.GetPort("1883/tcp"))
Expand Down

0 comments on commit e1b60db

Please sign in to comment.