@@ -3511,7 +3511,7 @@ func TestApplyTaskResultsToPipelineResults_Success(t *testing.T) {
3511
3511
results []v1beta1.PipelineResult
3512
3512
taskResults map [string ][]v1beta1.TaskRunResult
3513
3513
runResults map [string ][]v1beta1.CustomRunResult
3514
- skippedTasks []v1beta1. SkippedTask
3514
+ taskstatus map [ string ] string
3515
3515
expectedResults []v1beta1.PipelineRunResult
3516
3516
}{{
3517
3517
description : "non-reference-results" ,
@@ -3788,13 +3788,47 @@ func TestApplyTaskResultsToPipelineResults_Success(t *testing.T) {
3788
3788
Value : * v1beta1 .NewStructuredValues ("rae" ),
3789
3789
}},
3790
3790
},
3791
- skippedTasks : []v1beta1.SkippedTask {{
3792
- Name : "skippedTask" ,
3791
+ taskstatus : map [string ]string {PipelineTaskStatusPrefix + "skippedTask" + PipelineTaskStatusSuffix : PipelineTaskStateNone },
3792
+ expectedResults : nil ,
3793
+ }, {
3794
+ description : "unsuccessful-taskrun-no-results" ,
3795
+ results : []v1beta1.PipelineResult {{
3796
+ Name : "foo" ,
3797
+ Value : * v1beta1 .NewStructuredValues ("$(tasks.pt1.results.foo)" ),
3793
3798
}},
3799
+ taskResults : map [string ][]v1beta1.TaskRunResult {},
3800
+ taskstatus : map [string ]string {PipelineTaskStatusPrefix + "pt1" + PipelineTaskStatusSuffix : v1beta1 .TaskRunReasonFailed .String ()},
3794
3801
expectedResults : nil ,
3802
+ }, {
3803
+ description : "unsuccessful-taskrun-no-returned-result-object-ref" ,
3804
+ results : []v1beta1.PipelineResult {{
3805
+ Name : "foo" ,
3806
+ Value : * v1beta1 .NewStructuredValues ("$(tasks.pt1.results.foo.key1)" ),
3807
+ }},
3808
+ taskResults : map [string ][]v1beta1.TaskRunResult {},
3809
+ taskstatus : map [string ]string {PipelineTaskStatusPrefix + "pt1" + PipelineTaskStatusSuffix : v1beta1 .TaskRunReasonFailed .String ()},
3810
+ expectedResults : nil ,
3811
+ }, {
3812
+ description : "unsuccessful-taskrun-with-results" ,
3813
+ results : []v1beta1.PipelineResult {{
3814
+ Name : "foo" ,
3815
+ Value : * v1beta1 .NewStructuredValues ("$(tasks.pt1.results.foo[*])" ),
3816
+ }},
3817
+ taskResults : map [string ][]v1beta1.TaskRunResult {
3818
+ "pt1" : {
3819
+ {
3820
+ Name : "foo" ,
3821
+ Value : * v1beta1 .NewStructuredValues ("do" , "rae" , "mi" ),
3822
+ },
3823
+ }},
3824
+ taskstatus : map [string ]string {PipelineTaskStatusPrefix + "pt1" + PipelineTaskStatusSuffix : v1beta1 .TaskRunReasonFailed .String ()},
3825
+ expectedResults : []v1beta1.PipelineRunResult {{
3826
+ Name : "foo" ,
3827
+ Value : * v1beta1 .NewStructuredValues ("do" , "rae" , "mi" ),
3828
+ }},
3795
3829
}} {
3796
3830
t .Run (tc .description , func (t * testing.T ) {
3797
- received , err := ApplyTaskResultsToPipelineResults (context .Background (), tc .results , tc .taskResults , tc .runResults , tc .skippedTasks )
3831
+ received , err := ApplyTaskResultsToPipelineResults (context .Background (), tc .results , tc .taskResults , tc .runResults , tc .taskstatus )
3798
3832
if err != nil {
3799
3833
t .Errorf ("Got unecpected error:%v" , err )
3800
3834
}
@@ -3920,15 +3954,6 @@ func TestApplyTaskResultsToPipelineResults_Error(t *testing.T) {
3920
3954
},
3921
3955
expectedResults : nil ,
3922
3956
expectedError : fmt .Errorf ("invalid pipelineresults [foo], the referred results don't exist" ),
3923
- }, {
3924
- description : "unsuccessful-taskrun-no-returned-result" ,
3925
- results : []v1beta1.PipelineResult {{
3926
- Name : "foo" ,
3927
- Value : * v1beta1 .NewStructuredValues ("$(tasks.pt1.results.foo)" ),
3928
- }},
3929
- taskResults : map [string ][]v1beta1.TaskRunResult {},
3930
- expectedResults : nil ,
3931
- expectedError : fmt .Errorf ("invalid pipelineresults [foo], the referred results don't exist" ),
3932
3957
}, {
3933
3958
description : "mixed-success-tasks-some-returned-results" ,
3934
3959
results : []v1beta1.PipelineResult {{
@@ -4010,9 +4035,10 @@ func TestApplyTaskResultsToPipelineResults_Error(t *testing.T) {
4010
4035
expectedError : fmt .Errorf ("invalid pipelineresults [foo], the referred results don't exist" ),
4011
4036
}} {
4012
4037
t .Run (tc .description , func (t * testing.T ) {
4013
- received , err := ApplyTaskResultsToPipelineResults (context .Background (), tc .results , tc .taskResults , tc .runResults , nil /*skipped tasks*/ )
4038
+ received , err := ApplyTaskResultsToPipelineResults (context .Background (), tc .results , tc .taskResults , tc .runResults , nil /*tasks status */ )
4014
4039
if err == nil {
4015
4040
t .Errorf ("Expect error but got nil" )
4041
+ return
4016
4042
}
4017
4043
4018
4044
if d := cmp .Diff (tc .expectedError .Error (), err .Error ()); d != "" {
0 commit comments