2017-06-15 18:46:06 +02:00
|
|
|
package structs
|
2014-10-15 10:08:13 -07:00
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
2015-01-29 12:11:42 -08:00
|
|
|
"time"
|
2014-10-15 10:08:13 -07:00
|
|
|
)
|
|
|
|
|
2015-01-29 12:11:42 -08:00
|
|
|
func TestAgentStructs_CheckTypes(t *testing.T) {
|
2017-05-21 09:54:40 +02:00
|
|
|
t.Parallel()
|
2015-01-29 12:11:42 -08:00
|
|
|
svc := new(ServiceDefinition)
|
|
|
|
|
|
|
|
// Singular Check field works
|
|
|
|
svc.Check = CheckType{
|
|
|
|
Script: "/foo/bar",
|
|
|
|
Interval: 10 * time.Second,
|
|
|
|
}
|
|
|
|
|
|
|
|
// Returns HTTP checks
|
|
|
|
svc.Checks = append(svc.Checks, &CheckType{
|
|
|
|
HTTP: "http://foo/bar",
|
|
|
|
Interval: 10 * time.Second,
|
|
|
|
})
|
|
|
|
|
|
|
|
// Returns Script checks
|
|
|
|
svc.Checks = append(svc.Checks, &CheckType{
|
|
|
|
Script: "/foo/bar",
|
|
|
|
Interval: 10 * time.Second,
|
|
|
|
})
|
|
|
|
|
|
|
|
// Returns TTL checks
|
|
|
|
svc.Checks = append(svc.Checks, &CheckType{
|
|
|
|
TTL: 10 * time.Second,
|
|
|
|
})
|
|
|
|
|
|
|
|
// Does not return invalid checks
|
|
|
|
svc.Checks = append(svc.Checks, &CheckType{})
|
|
|
|
|
|
|
|
if len(svc.CheckTypes()) != 4 {
|
|
|
|
t.Fatalf("bad: %#v", svc)
|
|
|
|
}
|
|
|
|
}
|