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: "=",
|
||||
},
|
||||
},
|
||||
RestartPolicy: NewRestartPolicy(),
|
||||
Tasks: []*Task{
|
||||
&Task{
|
||||
Name: "task1",
|
||||
|
|
14
api/tasks.go
14
api/tasks.go
|
@ -12,6 +12,14 @@ type RestartPolicy struct {
|
|||
Delay time.Duration
|
||||
}
|
||||
|
||||
func NewRestartPolicy() *RestartPolicy {
|
||||
return &RestartPolicy{
|
||||
Attempts: 10,
|
||||
Interval: 3 * time.Minute,
|
||||
Delay: 5 * time.Second,
|
||||
}
|
||||
}
|
||||
|
||||
// TaskGroup is the unit of scheduling.
|
||||
type TaskGroup struct {
|
||||
Name string
|
||||
|
@ -24,9 +32,11 @@ type TaskGroup struct {
|
|||
|
||||
// NewTaskGroup creates a new TaskGroup.
|
||||
func NewTaskGroup(name string, count int) *TaskGroup {
|
||||
restartPolicy := NewRestartPolicy()
|
||||
return &TaskGroup{
|
||||
Name: name,
|
||||
Count: count,
|
||||
Name: name,
|
||||
Count: count,
|
||||
RestartPolicy: restartPolicy,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -8,8 +8,9 @@ import (
|
|||
func TestTaskGroup_NewTaskGroup(t *testing.T) {
|
||||
grp := NewTaskGroup("grp1", 2)
|
||||
expect := &TaskGroup{
|
||||
Name: "grp1",
|
||||
Count: 2,
|
||||
Name: "grp1",
|
||||
Count: 2,
|
||||
RestartPolicy: NewRestartPolicy(),
|
||||
}
|
||||
if !reflect.DeepEqual(grp, expect) {
|
||||
t.Fatalf("expect: %#v, got: %#v", expect, grp)
|
||||
|
|
Loading…
Reference in New Issue