...
1
2
3
4
5
6
7
8
9
10
11
12
13
14 package pushover
15
16 import (
17 "fmt"
18 "testing"
19
20 "github.com/go-kit/log"
21 commoncfg "github.com/prometheus/common/config"
22 "github.com/stretchr/testify/require"
23
24 "github.com/prometheus/alertmanager/config"
25 "github.com/prometheus/alertmanager/notify/test"
26 )
27
28 func TestPushoverRetry(t *testing.T) {
29 notifier, err := New(
30 &config.PushoverConfig{
31 HTTPConfig: &commoncfg.HTTPClientConfig{},
32 },
33 test.CreateTmpl(t),
34 log.NewNopLogger(),
35 )
36 require.NoError(t, err)
37 for statusCode, expected := range test.RetryTests(test.DefaultRetryCodes()) {
38 actual, _ := notifier.retrier.Check(statusCode, nil)
39 require.Equal(t, expected, actual, fmt.Sprintf("error on status %d", statusCode))
40 }
41 }
42
43 func TestPushoverRedactedURL(t *testing.T) {
44 ctx, u, fn := test.GetContextWithCancelingURL()
45 defer fn()
46
47 key, token := "user_key", "token"
48 notifier, err := New(
49 &config.PushoverConfig{
50 UserKey: config.Secret(key),
51 Token: config.Secret(token),
52 HTTPConfig: &commoncfg.HTTPClientConfig{},
53 },
54 test.CreateTmpl(t),
55 log.NewNopLogger(),
56 )
57 require.NoError(t, err)
58 notifier.apiURL = u.String()
59
60 test.AssertNotifyLeaksNoSecret(ctx, t, notifier, key, token)
61 }
62
View as plain text