telegraf/plugins/outputs/nats/nats_test.go

32 lines
713 B
Go
Raw Normal View History

2016-09-01 13:20:55 +00:00
package nats
import (
"testing"
"github.com/influxdata/telegraf/plugins/serializers"
"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")
}
server := []string{"nats://" + testutil.GetLocalHost() + ":4222"}
s, _ := serializers.NewInfluxSerializer()
n := &NATS{
Servers: server,
Subject: "telegraf",
serializer: s,
}
// Verify that we can connect to the NATS daemon
err := n.Connect()
require.NoError(t, err)
// Verify that we can successfully write data to the NATS daemon
err = n.Write(testutil.MockMetrics())
require.NoError(t, err)
}