2016-05-27 15:27:54 +00:00
|
|
|
package webhooks
|
|
|
|
|
|
|
|
import (
|
|
|
|
"reflect"
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
"github.com/influxdata/telegraf/plugins/inputs/webhooks/github"
|
2017-04-17 20:49:36 +00:00
|
|
|
"github.com/influxdata/telegraf/plugins/inputs/webhooks/papertrail"
|
2017-10-02 20:50:23 +00:00
|
|
|
"github.com/influxdata/telegraf/plugins/inputs/webhooks/particle"
|
2016-05-27 15:27:54 +00:00
|
|
|
"github.com/influxdata/telegraf/plugins/inputs/webhooks/rollbar"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestAvailableWebhooks(t *testing.T) {
|
|
|
|
wb := NewWebhooks()
|
|
|
|
expected := make([]Webhook, 0)
|
|
|
|
if !reflect.DeepEqual(wb.AvailableWebhooks(), expected) {
|
|
|
|
t.Errorf("expected to %v.\nGot %v", expected, wb.AvailableWebhooks())
|
|
|
|
}
|
|
|
|
|
|
|
|
wb.Github = &github.GithubWebhook{Path: "/github"}
|
|
|
|
expected = append(expected, wb.Github)
|
|
|
|
if !reflect.DeepEqual(wb.AvailableWebhooks(), expected) {
|
|
|
|
t.Errorf("expected to be %v.\nGot %v", expected, wb.AvailableWebhooks())
|
|
|
|
}
|
|
|
|
|
|
|
|
wb.Rollbar = &rollbar.RollbarWebhook{Path: "/rollbar"}
|
|
|
|
expected = append(expected, wb.Rollbar)
|
|
|
|
if !reflect.DeepEqual(wb.AvailableWebhooks(), expected) {
|
|
|
|
t.Errorf("expected to be %v.\nGot %v", expected, wb.AvailableWebhooks())
|
|
|
|
}
|
2017-04-17 20:49:36 +00:00
|
|
|
|
|
|
|
wb.Papertrail = &papertrail.PapertrailWebhook{Path: "/papertrail"}
|
|
|
|
expected = append(expected, wb.Papertrail)
|
|
|
|
if !reflect.DeepEqual(wb.AvailableWebhooks(), expected) {
|
|
|
|
t.Errorf("expected to be %v.\nGot %v", expected, wb.AvailableWebhooks())
|
|
|
|
}
|
2017-10-02 20:50:23 +00:00
|
|
|
wb.Particle = &particle.ParticleWebhook{Path: "/particle"}
|
|
|
|
expected = append(expected, wb.Particle)
|
|
|
|
if !reflect.DeepEqual(wb.AvailableWebhooks(), expected) {
|
|
|
|
t.Errorf("expected to be %v.\nGot %v", expected, wb.AvailableWebhooks())
|
|
|
|
}
|
2016-05-27 15:27:54 +00:00
|
|
|
}
|