1
0
Fork 0
mirror of https://github.com/prometheus-operator/prometheus-operator.git synced 2025-04-21 03:38:43 +00:00

Merge pull request from simonpasquier/add-global-config-test

pkg/alertmanager: add unit test for missing route
This commit is contained in:
Paweł Krupa 2022-07-13 12:39:53 +02:00 committed by GitHub
commit ea98ee5274
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 4 deletions
pkg/alertmanager

View file

@ -135,9 +135,7 @@ func (cb *configBuilder) initializeFromAlertmanagerConfig(ctx context.Context, a
}
// Add routes to globalAlertmanagerConfig.Route without enforce namespace
if convertedRoute := cb.convertRoute(amConfig.Spec.Route, crKey); convertedRoute != nil {
globalAlertmanagerConfig.Route = convertedRoute
}
globalAlertmanagerConfig.Route = cb.convertRoute(amConfig.Spec.Route, crKey)
for _, receiver := range amConfig.Spec.Receivers {
receivers, err := cb.convertReceiver(ctx, &receiver, crKey)

View file

@ -61,7 +61,7 @@ func TestGenerateGlobalConfig(t *testing.T) {
wantErr bool
}{
{
name: "generateGlobalConfig succeed",
name: "valid global config",
amConfig: &monitoringv1alpha1.AlertmanagerConfig{
ObjectMeta: metav1.ObjectMeta{
Name: "global-config",
@ -103,6 +103,16 @@ func TestGenerateGlobalConfig(t *testing.T) {
},
wantErr: false,
},
{
name: "missing route",
amConfig: &monitoringv1alpha1.AlertmanagerConfig{
ObjectMeta: metav1.ObjectMeta{
Name: "global-config",
Namespace: "mynamespace",
},
},
wantErr: true,
},
}
for _, tt := range tests {
version, err := semver.ParseTolerant("v0.22.2")