[Alerting] Ensure upstream validations are run (#34333)

* use embedded validations via noop yaml unmarshaler

* lint

* fixes integration tests now that groupings are handled
This commit is contained in:
Owen Diehl
2021-05-19 06:22:44 -04:00
committed by GitHub
parent aed1c013c0
commit d6c4c2fcd5
5 changed files with 85 additions and 14 deletions
@@ -7,6 +7,7 @@ import (
"testing"
"github.com/prometheus/alertmanager/config"
"github.com/prometheus/common/model"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"gopkg.in/yaml.v3"
@@ -563,3 +564,14 @@ func Test_ReceiverMatchesBackend(t *testing.T) {
})
}
}
func Test_Marshaling_Validation(t *testing.T) {
jsonEncoded, err := ioutil.ReadFile("alertmanager_test_artifact.json")
require.Nil(t, err)
var tmp GettableUserConfig
require.Nil(t, json.Unmarshal(jsonEncoded, &tmp))
expected := []model.LabelName{"alertname"}
require.Equal(t, expected, tmp.AlertmanagerConfig.Config.Route.GroupBy)
}