forked from go-pkgz/notify
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinterface_test.go
32 lines (26 loc) · 901 Bytes
/
interface_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
package notify
import (
"context"
"testing"
"github.com/stretchr/testify/assert"
)
func TestSend(t *testing.T) {
notifiers := []Notifier{NewWebhook(WebhookParams{})}
ctx, cancel := context.WithCancel(context.Background())
assert.EqualError(t,
Send(ctx, notifiers, "mailto:[email protected]", ""),
"unsupported destination schema: mailto")
assert.EqualError(t,
Send(ctx, notifiers, "bad destination", ""),
"unsupported destination schema: bad destination")
cancel()
assert.EqualError(t,
Send(ctx, notifiers, "https://example.org/webhook", ""),
`webhook request failed: Post "https://example.org/webhook": context canceled`)
}
func TestInterface(t *testing.T) {
assert.Implements(t, (*Notifier)(nil), new(Email))
assert.Implements(t, (*Notifier)(nil), new(Webhook))
assert.Implements(t, (*Notifier)(nil), new(Slack))
assert.Implements(t, (*Notifier)(nil), new(Telegram))
}