Fixed Go tests

This commit is contained in:
DazWilkin 2016-07-31 18:26:58 -07:00
parent ba5b46217c
commit 558afe7f04
1 changed files with 5 additions and 4 deletions

View File

@ -1,6 +1,7 @@
package particle package particle
import ( import (
"bytes"
"net/http" "net/http"
"net/http/httptest" "net/http/httptest"
"testing" "testing"
@ -8,10 +9,10 @@ import (
"github.com/influxdata/telegraf/testutil" "github.com/influxdata/telegraf/testutil"
) )
func ParticleWebhookRequest(urlEncodedString string, t *testing.T) { func ParticleWebhookRequest(event string, urlEncodedString string, t *testing.T) {
var acc testutil.Accumulator var acc testutil.Accumulator
pwh := &ParticleWebhook{Path: "/particle", acc: &acc} pwh := &ParticleWebhook{Path: "/particle", acc: &acc}
req, _ := http.NewRequest("POST", "/particle", urlEncodedString) req, _ := http.NewRequest("POST", "/particle", bytes.NewBufferString(urlEncodedString))
w := httptest.NewRecorder() w := httptest.NewRecorder()
pwh.eventHandler(w, req) pwh.eventHandler(w, req)
if w.Code != http.StatusOK { if w.Code != http.StatusOK {
@ -19,6 +20,6 @@ func ParticleWebhookRequest(urlEncodedString string, t *testing.T) {
} }
} }
func TestNewEvent(t *testing.T) { func TestParticleEvent(t *testing.T) {
ParticleWebhookRequest(NewEventURLEncoded()) ParticleWebhookRequest("particle_event", NewEventURLEncoded(), t)
} }