Add new webhooks plugin that superseed github and rollbar plugins.
closes #1289 Signed-off-by: François de Metz <francois@stormz.me> Signed-off-by: Cyril Duez <cyril@stormz.me> Rename internals struct. Signed-off-by: François de Metz <francois@stormz.me> Signed-off-by: Cyril Duez <cyril@stormz.me> Update changelog. Signed-off-by: François de Metz <francois@stormz.me> Signed-off-by: Cyril Duez <cyril@stormz.me> Update READMEs and CHANGELOG. Signed-off-by: François de Metz <francois@stormz.me> Signed-off-by: Cyril Duez <cyril@stormz.me> Update SampleConfig. Update the config format. Update telegraf config. Update the webhooks README. Update changelog. Update the changelog with an upgrade path. Update default ports. Fix indent. Check for nil value on AvailableWebhooks. Check for CanInterface.
This commit is contained in:
committed by
Cameron Sparr
parent
e3448153e1
commit
e603825e37
98
plugins/inputs/webhooks/github/github_webhooks_test.go
Normal file
98
plugins/inputs/webhooks/github/github_webhooks_test.go
Normal file
@@ -0,0 +1,98 @@
|
||||
package github
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/influxdata/telegraf/testutil"
|
||||
)
|
||||
|
||||
func GithubWebhookRequest(event string, jsonString string, t *testing.T) {
|
||||
var acc testutil.Accumulator
|
||||
gh := &GithubWebhook{Path: "/github", acc: &acc}
|
||||
req, _ := http.NewRequest("POST", "/github", strings.NewReader(jsonString))
|
||||
req.Header.Add("X-Github-Event", event)
|
||||
w := httptest.NewRecorder()
|
||||
gh.eventHandler(w, req)
|
||||
if w.Code != http.StatusOK {
|
||||
t.Errorf("POST "+event+" returned HTTP status code %v.\nExpected %v", w.Code, http.StatusOK)
|
||||
}
|
||||
}
|
||||
|
||||
func TestCommitCommentEvent(t *testing.T) {
|
||||
GithubWebhookRequest("commit_comment", CommitCommentEventJSON(), t)
|
||||
}
|
||||
|
||||
func TestDeleteEvent(t *testing.T) {
|
||||
GithubWebhookRequest("delete", DeleteEventJSON(), t)
|
||||
}
|
||||
|
||||
func TestDeploymentEvent(t *testing.T) {
|
||||
GithubWebhookRequest("deployment", DeploymentEventJSON(), t)
|
||||
}
|
||||
|
||||
func TestDeploymentStatusEvent(t *testing.T) {
|
||||
GithubWebhookRequest("deployment_status", DeploymentStatusEventJSON(), t)
|
||||
}
|
||||
|
||||
func TestForkEvent(t *testing.T) {
|
||||
GithubWebhookRequest("fork", ForkEventJSON(), t)
|
||||
}
|
||||
|
||||
func TestGollumEvent(t *testing.T) {
|
||||
GithubWebhookRequest("gollum", GollumEventJSON(), t)
|
||||
}
|
||||
|
||||
func TestIssueCommentEvent(t *testing.T) {
|
||||
GithubWebhookRequest("issue_comment", IssueCommentEventJSON(), t)
|
||||
}
|
||||
|
||||
func TestIssuesEvent(t *testing.T) {
|
||||
GithubWebhookRequest("issues", IssuesEventJSON(), t)
|
||||
}
|
||||
|
||||
func TestMemberEvent(t *testing.T) {
|
||||
GithubWebhookRequest("member", MemberEventJSON(), t)
|
||||
}
|
||||
|
||||
func TestMembershipEvent(t *testing.T) {
|
||||
GithubWebhookRequest("membership", MembershipEventJSON(), t)
|
||||
}
|
||||
|
||||
func TestPageBuildEvent(t *testing.T) {
|
||||
GithubWebhookRequest("page_build", PageBuildEventJSON(), t)
|
||||
}
|
||||
|
||||
func TestPublicEvent(t *testing.T) {
|
||||
GithubWebhookRequest("public", PublicEventJSON(), t)
|
||||
}
|
||||
|
||||
func TestPullRequestReviewCommentEvent(t *testing.T) {
|
||||
GithubWebhookRequest("pull_request_review_comment", PullRequestReviewCommentEventJSON(), t)
|
||||
}
|
||||
|
||||
func TestPushEvent(t *testing.T) {
|
||||
GithubWebhookRequest("push", PushEventJSON(), t)
|
||||
}
|
||||
|
||||
func TestReleaseEvent(t *testing.T) {
|
||||
GithubWebhookRequest("release", ReleaseEventJSON(), t)
|
||||
}
|
||||
|
||||
func TestRepositoryEvent(t *testing.T) {
|
||||
GithubWebhookRequest("repository", RepositoryEventJSON(), t)
|
||||
}
|
||||
|
||||
func TestStatusEvent(t *testing.T) {
|
||||
GithubWebhookRequest("status", StatusEventJSON(), t)
|
||||
}
|
||||
|
||||
func TestTeamAddEvent(t *testing.T) {
|
||||
GithubWebhookRequest("team_add", TeamAddEventJSON(), t)
|
||||
}
|
||||
|
||||
func TestWatchEvent(t *testing.T) {
|
||||
GithubWebhookRequest("watch", WatchEventJSON(), t)
|
||||
}
|
||||
Reference in New Issue
Block a user