mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-27 21:47:07 +00:00
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:
commit
b86297c837
@ -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},
|
"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 {
|
for name, tc := range testCases {
|
||||||
|
name := name
|
||||||
|
tc := tc
|
||||||
|
t.Run(name, func(t *testing.T) {
|
||||||
sj := cronJob()
|
sj := cronJob()
|
||||||
sj.Spec.ConcurrencyPolicy = tc.concurrencyPolicy
|
sj.Spec.ConcurrencyPolicy = tc.concurrencyPolicy
|
||||||
sj.Spec.Suspend = &tc.suspend
|
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) {
|
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))
|
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 {
|
for name, tc := range testCases {
|
||||||
|
name := name
|
||||||
|
tc := tc
|
||||||
|
t.Run(name, func(t *testing.T) {
|
||||||
sj := cronJob()
|
sj := cronJob()
|
||||||
suspend := false
|
suspend := false
|
||||||
sj.Spec.ConcurrencyPolicy = f
|
sj.Spec.ConcurrencyPolicy = f
|
||||||
@ -583,6 +590,7 @@ func TestCleanupFinishedJobs_DeleteOrNot(t *testing.T) {
|
|||||||
if tc.expectActive != numActive {
|
if tc.expectActive != numActive {
|
||||||
t.Errorf("%s: expected Active size %d, got %d", name, 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 {
|
for name, tc := range testCases {
|
||||||
|
name := name
|
||||||
|
tc := tc
|
||||||
|
t.Run(name, func(t *testing.T) {
|
||||||
// Setup the test
|
// Setup the test
|
||||||
sj := cronJob()
|
sj := cronJob()
|
||||||
sj.Spec.ConcurrencyPolicy = tc.concurrencyPolicy
|
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()) {
|
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)
|
t.Errorf("%s: expected LastScheduleTime updated to %s, got %s", name, topOfTheHour(), sjc.Updates[1].Status.LastScheduleTime)
|
||||||
}
|
}
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user