MQTT output unit tests w/ docker container

This commit is contained in:
Cameron Sparr
2015-11-13 13:37:24 -07:00
parent b975419bc7
commit a6ae597dfc
2 changed files with 31 additions and 2 deletions

27
outputs/mqtt/mqtt_test.go Normal file
View File

@@ -0,0 +1,27 @@
package mqtt
import (
"testing"
"github.com/influxdb/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"
m := &MQTT{
Servers: []string{url},
}
// 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.MockBatchPoints().Points())
require.NoError(t, err)
}