check test case param instead of feature flag in unit test code

This commit is contained in:
Daniel Vega-Myhre 2023-07-06 17:30:40 +00:00
parent a647f9febb
commit 3a02ecb341

View File

@ -882,7 +882,7 @@ func TestControllerSyncJob(t *testing.T) {
t.Errorf("Unexpected number of creates. Expected %d, saw %d\n", tc.expectedCreations, len(fakePodControl.Templates))
}
if tc.completionMode == batch.IndexedCompletion {
checkIndexedJobPods(t, &fakePodControl, tc.expectedCreatedIndexes, job.Name)
checkIndexedJobPods(t, &fakePodControl, tc.expectedCreatedIndexes, job.Name, tc.podIndexLabelDisabled)
} else {
for _, p := range fakePodControl.Templates {
// Fake pod control doesn't add generate name from the owner reference.
@ -969,12 +969,12 @@ func TestControllerSyncJob(t *testing.T) {
}
}
func checkIndexedJobPods(t *testing.T, control *controller.FakePodControl, wantIndexes sets.Set[int], jobName string) {
func checkIndexedJobPods(t *testing.T, control *controller.FakePodControl, wantIndexes sets.Set[int], jobName string, podIndexLabelDisabled bool) {
t.Helper()
gotIndexes := sets.New[int]()
for _, p := range control.Templates {
checkJobCompletionEnvVariable(t, &p.Spec)
if feature.DefaultFeatureGate.Enabled(features.PodIndexLabel) {
if !podIndexLabelDisabled {
checkJobCompletionLabel(t, &p)
}
ix := getCompletionIndex(p.Annotations)