2017-06-15 16:46:06 +00:00
|
|
|
package structs
|
2014-10-15 17:08:13 +00:00
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
2015-01-29 20:11:42 +00:00
|
|
|
"time"
|
2014-10-15 17:08:13 +00:00
|
|
|
)
|
|
|
|
|
2015-01-29 20:11:42 +00:00
|
|
|
func TestAgentStructs_CheckTypes(t *testing.T) {
|
2017-05-21 07:54:40 +00:00
|
|
|
t.Parallel()
|
2015-01-29 20:11:42 +00: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)
|
|
|
|
}
|
|
|
|
}
|