Added a RestartPolicy to some mocks

This commit is contained in:
Diptanu Choudhury 2015-10-30 21:28:56 -07:00
parent 8133aa413a
commit c80f0e38d1
3 changed files with 16 additions and 4 deletions

View File

@ -69,6 +69,7 @@ func TestCompose(t *testing.T) {
Operand: "=", Operand: "=",
}, },
}, },
RestartPolicy: NewRestartPolicy(),
Tasks: []*Task{ Tasks: []*Task{
&Task{ &Task{
Name: "task1", Name: "task1",

View File

@ -12,6 +12,14 @@ type RestartPolicy struct {
Delay time.Duration Delay time.Duration
} }
func NewRestartPolicy() *RestartPolicy {
return &RestartPolicy{
Attempts: 10,
Interval: 3 * time.Minute,
Delay: 5 * time.Second,
}
}
// TaskGroup is the unit of scheduling. // TaskGroup is the unit of scheduling.
type TaskGroup struct { type TaskGroup struct {
Name string Name string
@ -24,9 +32,11 @@ type TaskGroup struct {
// NewTaskGroup creates a new TaskGroup. // NewTaskGroup creates a new TaskGroup.
func NewTaskGroup(name string, count int) *TaskGroup { func NewTaskGroup(name string, count int) *TaskGroup {
restartPolicy := NewRestartPolicy()
return &TaskGroup{ return &TaskGroup{
Name: name, Name: name,
Count: count, Count: count,
RestartPolicy: restartPolicy,
} }
} }

View File

@ -10,6 +10,7 @@ func TestTaskGroup_NewTaskGroup(t *testing.T) {
expect := &TaskGroup{ expect := &TaskGroup{
Name: "grp1", Name: "grp1",
Count: 2, Count: 2,
RestartPolicy: NewRestartPolicy(),
} }
if !reflect.DeepEqual(grp, expect) { if !reflect.DeepEqual(grp, expect) {
t.Fatalf("expect: %#v, got: %#v", expect, grp) t.Fatalf("expect: %#v, got: %#v", expect, grp)