mirror of
https://github.com/prometheus-operator/prometheus-operator.git
synced 2025-04-21 03:38:43 +00:00
Merge pull request #4885 from simonpasquier/add-global-config-test
pkg/alertmanager: add unit test for missing route
This commit is contained in:
commit
ea98ee5274
2 changed files with 12 additions and 4 deletions
pkg/alertmanager
|
@ -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)
|
||||
|
|
|
@ -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")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue