Named fields in unit test and one more test case

This commit is contained in:
Preetha Appan 2018-01-17 16:34:15 -06:00
parent 5ee3cdecc5
commit 6fcd9f67a8
No known key found for this signature in database
GPG key ID: 9F7C19990A50EAFC

View file

@ -2429,16 +2429,28 @@ func TestReschedulePolicy_Validate(t *testing.T) {
testCases := []testCase{
{
ReschedulePolicy: &ReschedulePolicy{1, 5 * time.Minute},
err: nil,
ReschedulePolicy: &ReschedulePolicy{
Attempts: 0,
Interval: 0 * time.Second},
err: nil,
},
{
ReschedulePolicy: &ReschedulePolicy{-1, 5 * time.Minute},
err: nil,
ReschedulePolicy: &ReschedulePolicy{
Attempts: 1,
Interval: 5 * time.Minute},
err: nil,
},
{
ReschedulePolicy: &ReschedulePolicy{1, 1 * time.Second},
err: fmt.Errorf("Interval cannot be less than %v (got %v)", RestartPolicyMinInterval, time.Second),
ReschedulePolicy: &ReschedulePolicy{
Attempts: -1,
Interval: 5 * time.Minute},
err: nil,
},
{
ReschedulePolicy: &ReschedulePolicy{
Attempts: 1,
Interval: 1 * time.Second},
err: fmt.Errorf("Interval cannot be less than %v (got %v)", RestartPolicyMinInterval, time.Second),
},
}
@ -2701,6 +2713,14 @@ func TestAllocation_ShouldReschedule(t *testing.T) {
ReschedulePolicy: nil,
ShouldReschedule: false,
},
{
Desc: "Disabled recheduling",
ClientStatus: AllocClientStatusFailed,
DesiredStatus: AllocDesiredStatusRun,
FailTime: fail,
ReschedulePolicy: &ReschedulePolicy{0, 1 * time.Minute},
ShouldReschedule: false,
},
{
Desc: "Reschedule when client status is complete",
ClientStatus: AllocClientStatusComplete,