Merge pull request #89669 from yangkev/yangkev-make-tests-table-driven-patch

allow running cronjob controller unit tests individually by name
This commit is contained in:
Kubernetes Prow Robot 2020-04-15 13:14:58 -07:00 committed by GitHub
commit b86297c837
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -250,6 +250,9 @@ func TestSyncOne_RunOrNot(t *testing.T) {
"prev ran but done, long overdue, past short deadline, F": {f, F, onTheHour, shortDead, T, F, weekAfterTheHour(), T, F, 1, 0},
}
for name, tc := range testCases {
name := name
tc := tc
t.Run(name, func(t *testing.T) {
sj := cronJob()
sj.Spec.ConcurrencyPolicy = tc.concurrencyPolicy
sj.Spec.Suspend = &tc.suspend
@ -357,6 +360,7 @@ func TestSyncOne_RunOrNot(t *testing.T) {
if tc.expectActive != len(sjc.Updates[expectUpdates-1].Status.Active) {
t.Errorf("%s: expected Active size %d, got %d", name, tc.expectActive, len(sjc.Updates[expectUpdates-1].Status.Active))
}
})
}
}
@ -486,6 +490,9 @@ func TestCleanupFinishedJobs_DeleteOrNot(t *testing.T) {
}
for name, tc := range testCases {
name := name
tc := tc
t.Run(name, func(t *testing.T) {
sj := cronJob()
suspend := false
sj.Spec.ConcurrencyPolicy = f
@ -583,6 +590,7 @@ func TestCleanupFinishedJobs_DeleteOrNot(t *testing.T) {
if tc.expectActive != numActive {
t.Errorf("%s: expected Active size %d, got %d", name, tc.expectActive, numActive)
}
})
}
}
@ -669,6 +677,9 @@ func TestSyncOne_Status(t *testing.T) {
}
for name, tc := range testCases {
name := name
tc := tc
t.Run(name, func(t *testing.T) {
// Setup the test
sj := cronJob()
sj.Spec.ConcurrencyPolicy = tc.concurrencyPolicy
@ -761,5 +772,6 @@ func TestSyncOne_Status(t *testing.T) {
if tc.expectCreate && !sjc.Updates[1].Status.LastScheduleTime.Time.Equal(topOfTheHour()) {
t.Errorf("%s: expected LastScheduleTime updated to %s, got %s", name, topOfTheHour(), sjc.Updates[1].Status.LastScheduleTime)
}
})
}
}