28 lines
642 B
Go
28 lines
642 B
Go
package rules
|
|
|
|
import (
|
|
"errors"
|
|
"iwarma.ru/console/correlator/es"
|
|
"iwarma.ru/console/correlator/util"
|
|
"testing"
|
|
)
|
|
|
|
func TestStoreStringer(t *testing.T) {
|
|
util.SetupTest(t)
|
|
defer util.TearDownTest(t)
|
|
|
|
client, err := es.NewElastic()
|
|
if err != nil {
|
|
t.Errorf("%v", err)
|
|
return
|
|
}
|
|
|
|
store := NewRuleStore(client)
|
|
|
|
stat := store.GetStat()
|
|
stat.Errors["12"] = errors.New("test error").Error()
|
|
|
|
if stat.String() != `{"rule_count":0,"average_time":{"value":"0s"},"average_rule_time":{},"incident_count":0,"events_count":0,"errors":{"12":"test error"}}` {
|
|
t.Errorf("Got bad string representation: %v", store.GetStat().String())
|
|
}
|
|
}
|