Skip to content

Commit 25c2731

Browse files
committed
Job: Use type parameters instead of type casting for the ptr libraries
Signed-off-by: Yuki Iwai <[email protected]>
1 parent 1854839 commit 25c2731

File tree

1 file changed

+25
-25
lines changed

1 file changed

+25
-25
lines changed

test/integration/job/job_test.go

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ func validateTerminatedPodsTrackingFinalizerMetric(ctx context.Context, t *testi
118118
// Note: this scenario requires the use of finalizers. Without finalizers there is no guarantee a failed pod would be
119119
// checked against the pod failure policy rules before its removal by PodGC.
120120
func TestJobPodFailurePolicyWithFailedPodDeletedDuringControllerRestart(t *testing.T) {
121-
count := 3
121+
count := int32(3)
122122
job := batchv1.Job{
123123
Spec: batchv1.JobSpec{
124124
Template: v1.PodTemplateSpec{
@@ -133,8 +133,8 @@ func TestJobPodFailurePolicyWithFailedPodDeletedDuringControllerRestart(t *testi
133133
},
134134
},
135135
},
136-
Parallelism: ptr.To(int32(count)),
137-
Completions: ptr.To(int32(count)),
136+
Parallelism: &count,
137+
Completions: &count,
138138
PodFailurePolicy: &batchv1.PodFailurePolicy{
139139
Rules: []batchv1.PodFailurePolicyRule{
140140
{
@@ -181,7 +181,7 @@ func TestJobPodFailurePolicyWithFailedPodDeletedDuringControllerRestart(t *testi
181181
t.Fatalf("Failed to create Job: %v", err)
182182
}
183183
validateJobPodsStatus(ctx, t, cs, jobObj, podsByStatus{
184-
Active: count,
184+
Active: int(count),
185185
Ready: ptr.To[int32](0),
186186
Terminating: ptr.To[int32](0),
187187
})
@@ -541,7 +541,7 @@ func TestSuccessPolicy(t *testing.T) {
541541
wantFailed: 0,
542542
wantSucceeded: 1,
543543
wantCompletedIndexes: "0",
544-
wantTerminating: ptr.To(int32(0)),
544+
wantTerminating: ptr.To[int32](0),
545545
},
546546
},
547547
wantConditionTypes: []batchv1.JobConditionType{batchv1.JobSuccessCriteriaMet, batchv1.JobComplete},
@@ -576,7 +576,7 @@ func TestSuccessPolicy(t *testing.T) {
576576
wantFailed: 0,
577577
wantSucceeded: 1,
578578
wantCompletedIndexes: "0",
579-
wantTerminating: ptr.To(int32(0)),
579+
wantTerminating: ptr.To[int32](0),
580580
},
581581
},
582582
wantConditionTypes: []batchv1.JobConditionType{batchv1.JobComplete},
@@ -643,7 +643,7 @@ func TestSuccessPolicy(t *testing.T) {
643643
wantActiveIndexes: sets.New(0, 1),
644644
wantFailed: 0,
645645
wantSucceeded: 0,
646-
wantTerminating: ptr.To(int32(0)),
646+
wantTerminating: ptr.To[int32](0),
647647
},
648648
{
649649
index: 1,
@@ -654,7 +654,7 @@ func TestSuccessPolicy(t *testing.T) {
654654
wantFailed: 0,
655655
wantSucceeded: 1,
656656
wantCompletedIndexes: "1",
657-
wantTerminating: ptr.To(int32(1)),
657+
wantTerminating: ptr.To[int32](1),
658658
},
659659
},
660660
wantConditionTypes: []batchv1.JobConditionType{batchv1.JobSuccessCriteriaMet, batchv1.JobComplete},
@@ -690,7 +690,7 @@ func TestSuccessPolicy(t *testing.T) {
690690
wantActiveIndexes: sets.New(0, 1),
691691
wantFailed: 0,
692692
wantSucceeded: 0,
693-
wantTerminating: ptr.To(int32(0)),
693+
wantTerminating: ptr.To[int32](0),
694694
},
695695
{
696696
index: 1,
@@ -701,7 +701,7 @@ func TestSuccessPolicy(t *testing.T) {
701701
wantFailed: 0,
702702
wantSucceeded: 1,
703703
wantCompletedIndexes: "1",
704-
wantTerminating: ptr.To(int32(1)),
704+
wantTerminating: ptr.To[int32](1),
705705
},
706706
},
707707
wantConditionTypes: []batchv1.JobConditionType{batchv1.JobSuccessCriteriaMet, batchv1.JobComplete},
@@ -740,7 +740,7 @@ func TestSuccessPolicy(t *testing.T) {
740740
wantFailed: 1,
741741
wantFailedIndexes: ptr.To("0"),
742742
wantSucceeded: 0,
743-
wantTerminating: ptr.To(int32(0)),
743+
wantTerminating: ptr.To[int32](0),
744744
},
745745
{
746746
index: 1,
@@ -752,7 +752,7 @@ func TestSuccessPolicy(t *testing.T) {
752752
wantSucceeded: 1,
753753
wantFailedIndexes: ptr.To("0"),
754754
wantCompletedIndexes: "1",
755-
wantTerminating: ptr.To(int32(0)),
755+
wantTerminating: ptr.To[int32](0),
756756
},
757757
},
758758
wantConditionTypes: []batchv1.JobConditionType{batchv1.JobFailed},
@@ -1611,7 +1611,7 @@ func TestBackoffLimitPerIndex(t *testing.T) {
16111611
wantActiveIndexes: sets.New(0, 1),
16121612
wantFailedIndexes: ptr.To(""),
16131613
wantReplacementPodFailureCount: ptr.To(1),
1614-
wantTerminating: ptr.To(int32(0)),
1614+
wantTerminating: ptr.To[int32](0),
16151615
},
16161616
},
16171617
wantJobConditionType: batchv1.JobComplete,
@@ -1642,7 +1642,7 @@ func TestBackoffLimitPerIndex(t *testing.T) {
16421642
wantActiveIndexes: sets.New(0, 1),
16431643
wantFailedIndexes: ptr.To(""),
16441644
wantReplacementPodFailureCount: ptr.To(1),
1645-
wantTerminating: ptr.To(int32(0)),
1645+
wantTerminating: ptr.To[int32](0),
16461646
},
16471647
{
16481648
status: v1.PodStatus{
@@ -1653,7 +1653,7 @@ func TestBackoffLimitPerIndex(t *testing.T) {
16531653
wantActiveIndexes: sets.New(0, 1),
16541654
wantFailedIndexes: ptr.To(""),
16551655
wantReplacementPodFailureCount: ptr.To(2),
1656-
wantTerminating: ptr.To(int32(0)),
1656+
wantTerminating: ptr.To[int32](0),
16571657
},
16581658
{
16591659
status: v1.PodStatus{
@@ -1663,7 +1663,7 @@ func TestBackoffLimitPerIndex(t *testing.T) {
16631663
wantFailed: 3,
16641664
wantActiveIndexes: sets.New(1),
16651665
wantFailedIndexes: ptr.To("0"),
1666-
wantTerminating: ptr.To(int32(0)),
1666+
wantTerminating: ptr.To[int32](0),
16671667
},
16681668
},
16691669
wantJobConditionType: batchv1.JobFailed,
@@ -1699,7 +1699,7 @@ func TestBackoffLimitPerIndex(t *testing.T) {
16991699
wantFailed: 1,
17001700
wantActiveIndexes: sets.New(0, 1, 2),
17011701
wantFailedIndexes: ptr.To(""),
1702-
wantTerminating: ptr.To(int32(0)),
1702+
wantTerminating: ptr.To[int32](0),
17031703
},
17041704
{
17051705
index: 1,
@@ -1710,7 +1710,7 @@ func TestBackoffLimitPerIndex(t *testing.T) {
17101710
wantFailed: 2,
17111711
wantActiveIndexes: sets.New(0, 1, 2),
17121712
wantFailedIndexes: ptr.To(""),
1713-
wantTerminating: ptr.To(int32(0)),
1713+
wantTerminating: ptr.To[int32](0),
17141714
},
17151715
{
17161716
index: 2,
@@ -1719,7 +1719,7 @@ func TestBackoffLimitPerIndex(t *testing.T) {
17191719
},
17201720
wantFailed: 5,
17211721
wantFailedIndexes: ptr.To(""),
1722-
wantTerminating: ptr.To(int32(2)),
1722+
wantTerminating: ptr.To[int32](2),
17231723
},
17241724
},
17251725
wantJobConditionType: batchv1.JobFailed,
@@ -1754,7 +1754,7 @@ func TestBackoffLimitPerIndex(t *testing.T) {
17541754
wantFailed: 1,
17551755
wantActiveIndexes: sets.New(1),
17561756
wantFailedIndexes: ptr.To("0"),
1757-
wantTerminating: ptr.To(int32(0)),
1757+
wantTerminating: ptr.To[int32](0),
17581758
},
17591759
{
17601760
index: 1,
@@ -1765,7 +1765,7 @@ func TestBackoffLimitPerIndex(t *testing.T) {
17651765
wantSucceeded: 1,
17661766
wantFailedIndexes: ptr.To("0"),
17671767
wantCompletedIndexes: "1",
1768-
wantTerminating: ptr.To(int32(0)),
1768+
wantTerminating: ptr.To[int32](0),
17691769
},
17701770
},
17711771
wantJobConditionType: batchv1.JobFailed,
@@ -1801,7 +1801,7 @@ func TestBackoffLimitPerIndex(t *testing.T) {
18011801
wantFailed: 1,
18021802
wantActiveIndexes: sets.New(1, 2),
18031803
wantFailedIndexes: ptr.To("0"),
1804-
wantTerminating: ptr.To(int32(0)),
1804+
wantTerminating: ptr.To[int32](0),
18051805
},
18061806
{
18071807
index: 1,
@@ -1811,7 +1811,7 @@ func TestBackoffLimitPerIndex(t *testing.T) {
18111811
wantActive: 0,
18121812
wantFailed: 3,
18131813
wantFailedIndexes: ptr.To("0,1"),
1814-
wantTerminating: ptr.To(int32(1)),
1814+
wantTerminating: ptr.To[int32](1),
18151815
},
18161816
},
18171817
wantJobConditionType: batchv1.JobFailed,
@@ -1871,7 +1871,7 @@ func TestBackoffLimitPerIndex(t *testing.T) {
18711871
wantFailed: 1,
18721872
wantActiveIndexes: sets.New(1),
18731873
wantFailedIndexes: ptr.To("0"),
1874-
wantTerminating: ptr.To(int32(0)),
1874+
wantTerminating: ptr.To[int32](0),
18751875
},
18761876
{
18771877
index: 1,
@@ -1886,7 +1886,7 @@ func TestBackoffLimitPerIndex(t *testing.T) {
18861886
},
18871887
wantFailed: 2,
18881888
wantFailedIndexes: ptr.To("0,1"),
1889-
wantTerminating: ptr.To(int32(0)),
1889+
wantTerminating: ptr.To[int32](0),
18901890
},
18911891
},
18921892
wantJobConditionType: batchv1.JobFailed,

0 commit comments

Comments
 (0)