MCPcopy Index your code
hub / github.com/cortexproject/cortex / TestBuildNotifierConfig

Function TestBuildNotifierConfig

pkg/ruler/notifier_test.go:20–266  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

18)
19
20func TestBuildNotifierConfig(t *testing.T) {
21 tests := []struct {
22 name string
23 cfg *Config
24 ncfg *config.Config
25 err error
26 }{
27 {
28 name: "with no valid hosts, returns an empty config",
29 cfg: &Config{},
30 ncfg: &config.Config{},
31 },
32 {
33 name: "with a single URL and no service discovery",
34 cfg: &Config{
35 AlertmanagerURL: "http://alertmanager.default.svc.cluster.local/alertmanager",
36 },
37 ncfg: &config.Config{
38 AlertingConfig: config.AlertingConfig{
39 AlertmanagerConfigs: []*config.AlertmanagerConfig{
40 {
41 APIVersion: "v2",
42 Scheme: "http",
43 PathPrefix: "/alertmanager",
44 ServiceDiscoveryConfigs: discovery.Configs{
45 discovery.StaticConfig{
46 {
47 Targets: []model.LabelSet{{"__address__": "alertmanager.default.svc.cluster.local"}},
48 },
49 },
50 },
51 },
52 },
53 },
54 },
55 },
56 {
57 name: "with a single URL and service discovery",
58 cfg: &Config{
59 AlertmanagerURL: "http://_http._tcp.alertmanager.default.svc.cluster.local/alertmanager",
60 AlertmanagerDiscovery: true,
61 AlertmanagerRefreshInterval: time.Duration(60),
62 },
63 ncfg: &config.Config{
64 AlertingConfig: config.AlertingConfig{
65 AlertmanagerConfigs: []*config.AlertmanagerConfig{
66 {
67 APIVersion: "v2",
68 Scheme: "http",
69 PathPrefix: "/alertmanager",
70 ServiceDiscoveryConfigs: discovery.Configs{
71 &dns.SDConfig{
72 Names: []string{"_http._tcp.alertmanager.default.svc.cluster.local"},
73 RefreshInterval: 60,
74 Type: "SRV",
75 Port: 0,
76 },
77 },

Callers

nothing calls this directly

Calls 4

buildNotifierConfigFunction · 0.85
RunMethod · 0.65
EqualMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected