forked from influxdata/telegraf
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnats_test.go
More file actions
31 lines (25 loc) · 713 Bytes
/
nats_test.go
File metadata and controls
31 lines (25 loc) · 713 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
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)
}