Added a RestartPolicy to some mocks
This commit is contained in:
parent
8133aa413a
commit
c80f0e38d1
|
@ -69,6 +69,7 @@ func TestCompose(t *testing.T) {
|
||||||
Operand: "=",
|
Operand: "=",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
RestartPolicy: NewRestartPolicy(),
|
||||||
Tasks: []*Task{
|
Tasks: []*Task{
|
||||||
&Task{
|
&Task{
|
||||||
Name: "task1",
|
Name: "task1",
|
||||||
|
|
14
api/tasks.go
14
api/tasks.go
|
@ -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,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -8,8 +8,9 @@ import (
|
||||||
func TestTaskGroup_NewTaskGroup(t *testing.T) {
|
func TestTaskGroup_NewTaskGroup(t *testing.T) {
|
||||||
grp := NewTaskGroup("grp1", 2)
|
grp := NewTaskGroup("grp1", 2)
|
||||||
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)
|
||||||
|
|
Loading…
Reference in New Issue