...

Package test

import "github.com/prometheus/alertmanager/notify/test"
Overview
Index

Overview ▾

func AssertNotifyLeaksNoSecret

func AssertNotifyLeaksNoSecret(ctx context.Context, t *testing.T, n notify.Notifier, secret ...string)

AssertNotifyLeaksNoSecret calls the Notify() method of the notifier, expects it to fail because the context is canceled by the server and checks that no secret data is leaked in the error message returned by Notify().

func CreateTmpl

func CreateTmpl(t *testing.T) *template.Template

CreateTmpl returns a ready-to-use template.

func DefaultRetryCodes

func DefaultRetryCodes() []int

DefaultRetryCodes returns the list of HTTP status codes that need to be retried.

func GetContextWithCancelingURL

func GetContextWithCancelingURL(h ...func(w http.ResponseWriter, r *http.Request)) (context.Context, *url.URL, func())

GetContextWithCancelingURL returns a context that gets canceled when a client does a GET request to the returned URL. Handlers passed to the function will be invoked in order before the context gets canceled. The last argument is a function that needs to be called before the caller returns.

func RetryTests

func RetryTests(retryCodes []int) map[int]bool

RetryTests returns a map of HTTP status codes to bool indicating whether the notifier should retry or not.