@@ -1550,7 +1550,7 @@ func TestReconcileOnCompletedPipelineRun(t *testing.T) {
1550
1550
}}
1551
1551
ps := []* v1beta1.Pipeline {simpleHelloWorldPipeline }
1552
1552
ts := []* v1beta1.Task {simpleHelloWorldTask }
1553
- trs := []* v1beta1.TaskRun {createHelloWorldTaskRunWithStatus (taskRunName , "foo" ,
1553
+ trs := []* v1beta1.TaskRun {createHelloWorldTaskRunWithStatus (t , taskRunName , "foo" ,
1554
1554
"test-pipeline-run-completed" , "test-pipeline" , "" ,
1555
1555
apis.Condition {
1556
1556
Type : apis .ConditionSucceeded ,
@@ -1621,7 +1621,7 @@ func TestReconcileOnCancelledPipelineRunDeprecated(t *testing.T) {
1621
1621
prs := []* v1beta1.PipelineRun {createCancelledPipelineRun (t , "test-pipeline-run-cancelled" , v1beta1 .PipelineRunSpecStatusCancelledDeprecated )}
1622
1622
ps := []* v1beta1.Pipeline {simpleHelloWorldPipeline }
1623
1623
ts := []* v1beta1.Task {simpleHelloWorldTask }
1624
- trs := []* v1beta1.TaskRun {createHelloWorldTaskRun ("test-pipeline-run-cancelled-hello-world" , "foo" ,
1624
+ trs := []* v1beta1.TaskRun {createHelloWorldTaskRun (t , "test-pipeline-run-cancelled-hello-world" , "foo" ,
1625
1625
"test-pipeline-run-cancelled" , "test-pipeline" )}
1626
1626
1627
1627
d := test.Data {
@@ -1666,7 +1666,7 @@ func TestReconcileOnCancelledPipelineRun(t *testing.T) {
1666
1666
prs := []* v1beta1.PipelineRun {createCancelledPipelineRun (t , "test-pipeline-run-cancelled" , v1beta1 .PipelineRunSpecStatusCancelled )}
1667
1667
ps := []* v1beta1.Pipeline {simpleHelloWorldPipeline }
1668
1668
ts := []* v1beta1.Task {simpleHelloWorldTask }
1669
- trs := []* v1beta1.TaskRun {createHelloWorldTaskRun ("test-pipeline-run-cancelled-hello-world" , "foo" ,
1669
+ trs := []* v1beta1.TaskRun {createHelloWorldTaskRun (t , "test-pipeline-run-cancelled-hello-world" , "foo" ,
1670
1670
"test-pipeline-run-cancelled" , "test-pipeline" )}
1671
1671
cms := getConfigMapsWithEnabledAlphaAPIFields ()
1672
1672
@@ -2118,13 +2118,13 @@ func TestReconcileOnCancelledRunFinallyPipelineRunWithRunningFinalTask(t *testin
2118
2118
simpleSomeTask ,
2119
2119
}
2120
2120
trs := []* v1beta1.TaskRun {
2121
- createHelloWorldTaskRunWithStatus ("test-pipeline-run-cancelled-run-finally-hello-world" , "foo" ,
2121
+ createHelloWorldTaskRunWithStatus (t , "test-pipeline-run-cancelled-run-finally-hello-world" , "foo" ,
2122
2122
"test-pipeline-run-cancelled-run-finally" , "test-pipeline" , "my-pod-name" ,
2123
2123
apis.Condition {
2124
2124
Type : apis .ConditionSucceeded ,
2125
2125
Status : corev1 .ConditionTrue ,
2126
2126
}),
2127
- createHelloWorldTaskRun ("test-pipeline-run-cancelled-run-finally-final-task" , "foo" ,
2127
+ createHelloWorldTaskRun (t , "test-pipeline-run-cancelled-run-finally-final-task" , "foo" ,
2128
2128
"test-pipeline-run-cancelled-run-finally" , "test-pipeline" ),
2129
2129
}
2130
2130
cms := getConfigMapsWithEnabledAlphaAPIFields ()
@@ -2224,7 +2224,7 @@ func TestReconcileOnCancelledRunFinallyPipelineRunWithFinalTaskAndRetries(t *tes
2224
2224
}}
2225
2225
2226
2226
// TaskRun exists for DAG task "hello-world-1" that has failed with reason of cancellation
2227
- trs := []* v1beta1.TaskRun {createHelloWorldTaskRunWithStatus ("test-pipeline-run-cancelled-run-finally-hello-world" , "foo" ,
2227
+ trs := []* v1beta1.TaskRun {createHelloWorldTaskRunWithStatus (t , "test-pipeline-run-cancelled-run-finally-hello-world" , "foo" ,
2228
2228
"test-pipeline-run-cancelled-run-finally" , "test-pipeline" , "my-pod-name" ,
2229
2229
apis.Condition {
2230
2230
Type : apis .ConditionSucceeded ,
@@ -2305,6 +2305,7 @@ func TestReconcileCancelledRunFinallyFailsTaskRunCancellation(t *testing.T) {
2305
2305
}
2306
2306
trs := []* v1beta1.TaskRun {
2307
2307
getTaskRun (
2308
+ t ,
2308
2309
"test-pipeline-fails-to-cancelhello-world-1" ,
2309
2310
prName ,
2310
2311
"test-pipeline" ,
@@ -2412,6 +2413,7 @@ func TestReconcileTaskResolutionError(t *testing.T) {
2412
2413
}}
2413
2414
trs := []* v1beta1.TaskRun {
2414
2415
getTaskRun (
2416
+ t ,
2415
2417
"test-pipeline-fails-task-resolutionhello-world-1" ,
2416
2418
prName ,
2417
2419
"test-pipeline" ,
@@ -2555,6 +2557,7 @@ func TestReconcileOnStoppedRunFinallyPipelineRunWithRunningTask(t *testing.T) {
2555
2557
ts := []* v1beta1.Task {simpleHelloWorldTask }
2556
2558
trs := []* v1beta1.TaskRun {
2557
2559
getTaskRun (
2560
+ t ,
2558
2561
"test-pipeline-run-stopped-run-finally-hello-world" ,
2559
2562
"test-pipeline-run-stopped-run-finally" ,
2560
2563
"test-pipeline" ,
@@ -2650,6 +2653,7 @@ func TestReconcileOnStoppedPipelineRunWithCompletedTask(t *testing.T) {
2650
2653
ts := []* v1beta1.Task {simpleHelloWorldTask }
2651
2654
trs := []* v1beta1.TaskRun {
2652
2655
getTaskRun (
2656
+ t ,
2653
2657
"test-pipeline-run-stopped-hello-world" ,
2654
2658
"test-pipeline-run-stopped" ,
2655
2659
"test-pipeline" ,
@@ -6952,13 +6956,15 @@ func TestReconcilePipeline_FinalTasks(t *testing.T) {
6952
6956
6953
6957
trs : []* v1beta1.TaskRun {
6954
6958
getTaskRun (
6959
+ t ,
6955
6960
"task-run-dag-task" ,
6956
6961
"pipeline-run-dag-task-failing" ,
6957
6962
"pipeline-dag-task-failing" ,
6958
6963
"dag-task-1" ,
6959
6964
corev1 .ConditionFalse ,
6960
6965
),
6961
6966
getTaskRun (
6967
+ t ,
6962
6968
"task-run-final-task" ,
6963
6969
"pipeline-run-dag-task-failing" ,
6964
6970
"pipeline-dag-task-failing" ,
@@ -7016,13 +7022,15 @@ func TestReconcilePipeline_FinalTasks(t *testing.T) {
7016
7022
7017
7023
trs : []* v1beta1.TaskRun {
7018
7024
getTaskRun (
7025
+ t ,
7019
7026
"task-run-dag-task" ,
7020
7027
"pipeline-run-with-dag-successful-but-final-failing" ,
7021
7028
"pipeline-with-dag-successful-but-final-failing" ,
7022
7029
"dag-task-1" ,
7023
7030
"" ,
7024
7031
),
7025
7032
getTaskRun (
7033
+ t ,
7026
7034
"task-run-final-task" ,
7027
7035
"pipeline-run-with-dag-successful-but-final-failing" ,
7028
7036
"pipeline-with-dag-successful-but-final-failing" ,
@@ -7080,13 +7088,15 @@ func TestReconcilePipeline_FinalTasks(t *testing.T) {
7080
7088
7081
7089
trs : []* v1beta1.TaskRun {
7082
7090
getTaskRun (
7091
+ t ,
7083
7092
"task-run-dag-task" ,
7084
7093
"pipeline-run-with-dag-and-final-failing" ,
7085
7094
"pipeline-with-dag-and-final-failing" ,
7086
7095
"dag-task-1" ,
7087
7096
corev1 .ConditionFalse ,
7088
7097
),
7089
7098
getTaskRun (
7099
+ t ,
7090
7100
"task-run-final-task" ,
7091
7101
"pipeline-run-with-dag-and-final-failing" ,
7092
7102
"pipeline-with-dag-and-final-failing" ,
@@ -7151,13 +7161,15 @@ func TestReconcilePipeline_FinalTasks(t *testing.T) {
7151
7161
7152
7162
trs : []* v1beta1.TaskRun {
7153
7163
getTaskRun (
7164
+ t ,
7154
7165
"task-run-dag-task-1" ,
7155
7166
"pipeline-run-with-dag-running" ,
7156
7167
"pipeline-with-dag-running" ,
7157
7168
"dag-task-1" ,
7158
7169
corev1 .ConditionFalse ,
7159
7170
),
7160
7171
getTaskRun (
7172
+ t ,
7161
7173
"task-run-dag-task-2" ,
7162
7174
"pipeline-run-with-dag-running" ,
7163
7175
"pipeline-with-dag-running" ,
@@ -7216,6 +7228,7 @@ func TestReconcilePipeline_FinalTasks(t *testing.T) {
7216
7228
7217
7229
trs : []* v1beta1.TaskRun {
7218
7230
getTaskRun (
7231
+ t ,
7219
7232
"task-run-dag-task-1" ,
7220
7233
"pipeline-run-dag-task-running" ,
7221
7234
"pipeline-dag-task-running" ,
@@ -7328,8 +7341,8 @@ func getPipeline(p string, spec v1beta1.PipelineSpec) []*v1beta1.Pipeline {
7328
7341
return ps
7329
7342
}
7330
7343
7331
- func getTaskRun (tr , pr , p , t string , status corev1.ConditionStatus ) * v1beta1.TaskRun {
7332
- return createHelloWorldTaskRunWithStatusTaskLabel (tr , "foo" , pr , p , "" , t ,
7344
+ func getTaskRun (t * testing. T , tr , pr , p , tl string , status corev1.ConditionStatus ) * v1beta1.TaskRun {
7345
+ return createHelloWorldTaskRunWithStatusTaskLabel (t , tr , "foo" , pr , p , "" , tl ,
7333
7346
apis.Condition {
7334
7347
Type : apis .ConditionSucceeded ,
7335
7348
Status : status ,
@@ -8422,8 +8435,12 @@ func taskRunObjectMeta(trName, ns, prName, pipelineName, pipelineTaskName string
8422
8435
return om
8423
8436
}
8424
8437
8425
- func createHelloWorldTaskRunWithStatus (trName , ns , prName , pName , podName string , condition apis.Condition ) * v1beta1.TaskRun {
8426
- p := createHelloWorldTaskRun (trName , ns , prName , pName )
8438
+ func createHelloWorldTaskRunWithStatus (
8439
+ t * testing.T ,
8440
+ trName , ns , prName , pName , podName string ,
8441
+ condition apis.Condition ,
8442
+ ) * v1beta1.TaskRun {
8443
+ p := createHelloWorldTaskRun (t , trName , ns , prName , pName )
8427
8444
p .Status = v1beta1.TaskRunStatus {
8428
8445
Status : duckv1beta1.Status {
8429
8446
Conditions : duckv1beta1.Conditions {condition },
@@ -8435,34 +8452,30 @@ func createHelloWorldTaskRunWithStatus(trName, ns, prName, pName, podName string
8435
8452
return p
8436
8453
}
8437
8454
8438
- func createHelloWorldTaskRunWithStatusTaskLabel (trName , ns , prName , pName , podName , taskLabel string , condition apis.Condition ) * v1beta1.TaskRun {
8439
- p := createHelloWorldTaskRunWithStatus (trName , ns , prName , pName , podName , condition )
8455
+ func createHelloWorldTaskRunWithStatusTaskLabel (
8456
+ t * testing.T ,
8457
+ trName , ns , prName , pName , podName , taskLabel string ,
8458
+ condition apis.Condition ,
8459
+ ) * v1beta1.TaskRun {
8460
+ p := createHelloWorldTaskRunWithStatus (t , trName , ns , prName , pName , podName , condition )
8440
8461
p .Labels [pipeline .PipelineTaskLabelKey ] = taskLabel
8441
8462
8442
8463
return p
8443
8464
}
8444
8465
8445
- func createHelloWorldTaskRun (trName , ns , prName , pName string ) * v1beta1.TaskRun {
8446
- return & v1beta1.TaskRun {
8447
- ObjectMeta : metav1.ObjectMeta {
8448
- Name : trName ,
8449
- Namespace : ns ,
8450
- OwnerReferences : []metav1.OwnerReference {{
8451
- Kind : "kind" ,
8452
- Name : "name" ,
8453
- }},
8454
- Labels : map [string ]string {
8455
- pipeline .PipelineLabelKey : pName ,
8456
- pipeline .PipelineRunLabelKey : prName ,
8457
- },
8458
- },
8459
- Spec : v1beta1.TaskRunSpec {
8460
- TaskRef : & v1beta1.TaskRef {
8461
- Name : "hello-world" ,
8462
- },
8463
- ServiceAccountName : "test-sa" ,
8464
- },
8465
- }
8466
+ func createHelloWorldTaskRun (t * testing.T , trName , ns , prName , pName string ) * v1beta1.TaskRun {
8467
+ return parse .MustParseTaskRun (t , fmt .Sprintf (`
8468
+ metadata:
8469
+ name: %s
8470
+ namespace: %s
8471
+ labels:
8472
+ %s: %s
8473
+ %s: %s
8474
+ spec:
8475
+ taskRef:
8476
+ name: hello-world
8477
+ serviceAccountName: test-sa
8478
+ ` , trName , ns , pipeline .PipelineLabelKey , pName , pipeline .PipelineRunLabelKey , prName ))
8466
8479
}
8467
8480
8468
8481
func createCancelledPipelineRun (t * testing.T , prName string , specStatus v1beta1.PipelineRunSpecStatus ) * v1beta1.PipelineRun {
0 commit comments