2020-11-27 05:45:17 +01:00
|
|
|
package core
|
|
|
|
|
2020-12-30 02:22:17 +01:00
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
"time"
|
|
|
|
)
|
2020-11-27 05:45:17 +01:00
|
|
|
|
|
|
|
func TestNewServiceStatus(t *testing.T) {
|
2020-11-30 14:44:58 +01:00
|
|
|
service := &Service{Name: "name", Group: "group"}
|
2020-11-27 05:45:17 +01:00
|
|
|
serviceStatus := NewServiceStatus(service)
|
2020-11-30 14:44:58 +01:00
|
|
|
if serviceStatus.Name != service.Name {
|
|
|
|
t.Errorf("expected %s, got %s", service.Name, serviceStatus.Name)
|
|
|
|
}
|
2020-11-27 05:45:17 +01:00
|
|
|
if serviceStatus.Group != service.Group {
|
|
|
|
t.Errorf("expected %s, got %s", service.Group, serviceStatus.Group)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestServiceStatus_AddResult(t *testing.T) {
|
2020-11-30 14:44:58 +01:00
|
|
|
service := &Service{Name: "name", Group: "group"}
|
2020-11-27 05:45:17 +01:00
|
|
|
serviceStatus := NewServiceStatus(service)
|
|
|
|
for i := 0; i < 50; i++ {
|
2020-12-30 02:22:17 +01:00
|
|
|
serviceStatus.AddResult(&Result{Timestamp: time.Now()})
|
2020-11-27 05:45:17 +01:00
|
|
|
}
|
|
|
|
if len(serviceStatus.Results) != 20 {
|
|
|
|
t.Errorf("expected serviceStatus.Results to not exceed a length of 20")
|
|
|
|
}
|
|
|
|
}
|