Documentation
¶
Overview ¶
Package testutil builds a bridge with fake collaborators, for the tests of the packages above it.
Index ¶
- Constants
- func GroupID() string
- func ProbeBoard(t *testing.T) *probenow.Board
- type AM
- func (a *AM) CreateAgentSilence(_ context.Context, l map[string]string, _, _ time.Time, _, _ string) (string, error)
- func (a *AM) CreateSilence(_ context.Context, l map[string]string, _, _ time.Time, _, _ string) (string, error)
- func (a *AM) ExpireSilence(_ context.Context, id string) error
- func (a *AM) Silences(context.Context) ([]alertmanager.Silence, error)
- type Bot
- type Env
Constants ¶
const GroupKey = `{}:{alertname="ServiceDown",service="hub-example-com"}`
GroupKey is the key of the group New fires; GroupID is its id.
Variables ¶
This section is empty.
Functions ¶
func ProbeBoard ¶
ProbeBoard is a board of requests to probe on demand over two locations, edge-1 (overseas) and edge-2 (mainland), and these target sets:
all-web.yaml https://hub.example.com/ (service hub-example-com, the alert's; module http_head) all-tls.yaml https://hub.example.com/ again, module tls_expiry all-docs.yaml https://docs.example.com/ and https://www.example.com/ (service docs) overseas-api.yaml https://api.example.com/ (service api): edge-1 alone probes it
Types ¶
type AM ¶
type AM struct {
Created []map[string]string
Agents []map[string]string // agents' silences, which mute nothing
Expired []string
// contains filtered or unexported fields
}
AM is a fake silencer, standing in for the router.
func (*AM) CreateAgentSilence ¶
func (*AM) CreateSilence ¶
type Bot ¶
type Bot struct {
Texts []string
// contains filtered or unexported fields
}
Bot is a fake group bot.
type Env ¶
type Env struct {
Bridge *bridge.Bridge
Store *store.Store
AM *AM
Bot *Bot
// Location is the configured zone, the one the bridge formats times with; tests that check
// formatted dates read it rather than the process's own zone (CI runs UTC, the config does not).
Location *time.Location
}
Env is a bridge on a temporary store, with no Feishu app (alerts go to the fake bot).
func NewWith ¶
NewWith is New with a last word on the bridge's dependencies, for tests that add a collaborator.
func WithAgentRun ¶
WithAgentRun seeds a pending reference delivery without making a network call.