2016-07-31 23:56:28 +00:00
|
|
|
package particle
|
|
|
|
|
|
|
|
import (
|
2016-08-01 00:30:34 +00:00
|
|
|
"net/http"
|
|
|
|
"net/http/httptest"
|
|
|
|
"testing"
|
2016-07-31 23:56:28 +00:00
|
|
|
|
2016-08-01 00:30:34 +00:00
|
|
|
"github.com/influxdata/telegraf/testutil"
|
2016-07-31 23:56:28 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
func ParticleWebhookRequest(urlEncodedString string, t *testing.T) {
|
|
|
|
var acc testutil.Accumulator
|
2016-08-01 00:30:34 +00:00
|
|
|
pwh := &ParticleWebhook{Path: "/particle", acc: &acc}
|
2016-07-31 23:56:28 +00:00
|
|
|
req, _ := http.NewRequest("POST", "/particle", urlEncodedString)
|
|
|
|
w := httptest.NewRecorder()
|
|
|
|
pwh.eventHandler(w, req)
|
|
|
|
if w.Code != http.StatusOK {
|
|
|
|
t.Errorf("POST "+event+" returned HTTP status code %v.\nExpected %v", w.Code, http.StatusOK)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestNewEvent(t *testing.T) {
|
2016-08-01 00:30:34 +00:00
|
|
|
ParticleWebhookRequest(NewEventURLEncoded())
|
|
|
|
}
|