re-arrange and cleanup graphite output test

This commit is contained in:
Cameron Sparr 2016-02-09 11:01:13 -07:00
parent c09884c686
commit fb75db2f1f
1 changed files with 7 additions and 7 deletions

View File

@ -40,6 +40,10 @@ func TestGraphiteError(t *testing.T) {
func TestGraphiteOK(t *testing.T) { func TestGraphiteOK(t *testing.T) {
var wg sync.WaitGroup var wg sync.WaitGroup
// Start TCP server
wg.Add(1)
go TCPServer(t, &wg)
// Init plugin // Init plugin
g := Graphite{ g := Graphite{
Prefix: "my.prefix", Prefix: "my.prefix",
@ -63,19 +67,15 @@ func TestGraphiteOK(t *testing.T) {
map[string]interface{}{"value": float64(3.14)}, map[string]interface{}{"value": float64(3.14)},
time.Date(2010, time.November, 10, 23, 0, 0, 0, time.UTC), time.Date(2010, time.November, 10, 23, 0, 0, 0, time.UTC),
) )
// Prepare point list // Prepare point list
var metrics []telegraf.Metric metrics := []telegraf.Metric{m1, m2, m3}
metrics = append(metrics, m1)
metrics = append(metrics, m2)
metrics = append(metrics, m3)
// Start TCP server
wg.Add(1)
go TCPServer(t, &wg)
err1 := g.Connect() err1 := g.Connect()
require.NoError(t, err1) require.NoError(t, err1)
// Send Data // Send Data
err2 := g.Write(metrics) err2 := g.Write(metrics)
require.NoError(t, err2) require.NoError(t, err2)
// Waiting TCPserver // Waiting TCPserver
wg.Wait() wg.Wait()
g.Close() g.Close()