mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2024-11-21 14:44:00 +00:00
156c83d112
* app/vmalert: support multiple notifier urls (#584) User now can set multiple notifier URLs in the same fashion as for other vmutils (e.g. vmagent). The same is correct for TLS setting for every configured URL. Alerts sending is done in sequential way for respecting the specified URLs order. * app/vmalert: add basicAuth support for notifier client (#585) The change adds possibility to set basicAuth creds for notifier client in the same fasion as for remote write/read and datasource.
38 lines
711 B
Go
38 lines
711 B
Go
package utils
|
|
|
|
import (
|
|
"errors"
|
|
"testing"
|
|
)
|
|
|
|
func TestErrGroup(t *testing.T) {
|
|
testCases := []struct {
|
|
errs []error
|
|
exp string
|
|
}{
|
|
{nil, ""},
|
|
{[]error{errors.New("timeout")}, "errors(1): timeout"},
|
|
{
|
|
[]error{errors.New("timeout"), errors.New("deadline")},
|
|
"errors(2): timeout\ndeadline",
|
|
},
|
|
}
|
|
for _, tc := range testCases {
|
|
eg := new(ErrGroup)
|
|
for _, err := range tc.errs {
|
|
eg.Add(err)
|
|
}
|
|
if len(tc.errs) == 0 {
|
|
if eg.Err() != nil {
|
|
t.Fatalf("expected to get nil error")
|
|
}
|
|
continue
|
|
}
|
|
if eg.Err() == nil {
|
|
t.Fatalf("expected to get non-nil error")
|
|
}
|
|
if eg.Error() != tc.exp {
|
|
t.Fatalf("expected to have: \n%q\ngot:\n%q", tc.exp, eg.Error())
|
|
}
|
|
}
|
|
}
|