telegraf/plugins/outputs/mqtt/mqtt_test.go

32 lines
673 B
Go
Raw Normal View History

package mqtt
import (
"testing"
"github.com/influxdata/telegraf/plugins/serializers"
2016-01-20 18:57:35 +00:00
"github.com/influxdata/telegraf/testutil"
"github.com/stretchr/testify/require"
)
func TestConnectAndWrite(t *testing.T) {
if testing.Short() {
t.Skip("Skipping integration test in short mode")
}
var url = testutil.GetLocalHost() + ":1883"
s, _ := serializers.NewInfluxSerializer()
m := &MQTT{
Servers: []string{url},
serializer: s,
}
// Verify that we can connect to the MQTT broker
err := m.Connect()
require.NoError(t, err)
// Verify that we can successfully write data to the mqtt broker
err = m.Write(testutil.MockMetrics())
require.NoError(t, err)
}