mirror of
https://github.com/prometheus/alertmanager
synced 2025-01-01 02:52:06 +00:00
25e4bb9965
This is similar to `promtool check-config` and allows one to validate the alertmanager configuration (as a git presubmit for example). `govendor fetch github.com/spf13/{cobra,pflag}` was needed to have support for `Args`.
18 lines
333 B
Go
18 lines
333 B
Go
package cli
|
|
|
|
import (
|
|
"testing"
|
|
)
|
|
|
|
func TestCheckConfig(t *testing.T) {
|
|
err := CheckConfig([]string{"testdata/conf.good.yml"})
|
|
if err != nil {
|
|
t.Fatalf("Checking valid config file failed with: %v", err)
|
|
}
|
|
|
|
err = CheckConfig([]string{"testdata/conf.bad.yml"})
|
|
if err == nil {
|
|
t.Fatalf("Failed to detect invalid file.")
|
|
}
|
|
}
|