Fixed Go tests
This commit is contained in:
parent
ba5b46217c
commit
558afe7f04
|
@ -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)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue