@@ -2624,6 +2624,53 @@ func TestResolvePipelineRun_CustomTask(t *testing.T) {
26242624 }
26252625}
26262626
2627+ func TestResolvePipelineRun_ChildPipeline (t * testing.T ) {
2628+ cfg := config .NewStore (logtesting .TestLogger (t ))
2629+ ctx := cfg .ToContext (t .Context ())
2630+
2631+ parentPr := v1.PipelineRun {ObjectMeta : metav1.ObjectMeta {Name : "pipelinerun" }}
2632+ pinpPts := []v1.PipelineTask {pts [21 ], pts [22 ]}
2633+ getChildPipelineRun := func (name string ) (* v1.PipelineRun , error ) {
2634+ if name == "pipelinerun-mytask23" {
2635+ return & prs [1 ], nil
2636+ }
2637+ return nil , kerrors .NewNotFound (v1 .Resource ("pipelinerun" ), name )
2638+ }
2639+ expectedState := PipelineRunState {{
2640+ PipelineTask : & pinpPts [0 ],
2641+ ChildPipelineRunNames : []string {"pipelinerun-mytask22" },
2642+ ChildPipelineRuns : nil ,
2643+ ResolvedPipeline : ResolvedPipeline {PipelineSpec : pinpPts [0 ].PipelineSpec },
2644+ }, {
2645+ PipelineTask : & pinpPts [1 ],
2646+ ChildPipelineRunNames : []string {"pipelinerun-mytask23" },
2647+ ChildPipelineRuns : []* v1.PipelineRun {& prs [1 ]},
2648+ ResolvedPipeline : ResolvedPipeline {PipelineSpec : pinpPts [1 ].PipelineSpec },
2649+ }}
2650+ actualState := PipelineRunState {}
2651+
2652+ for _ , pipelineTask := range pinpPts {
2653+ ps , err := ResolvePipelineTask (
2654+ ctx ,
2655+ parentPr ,
2656+ getChildPipelineRun ,
2657+ nopGetTask ,
2658+ nopGetTaskRun ,
2659+ nopGetCustomRun ,
2660+ pipelineTask ,
2661+ nil ,
2662+ )
2663+ if err != nil {
2664+ t .Fatalf ("ResolvePipelineTask: %v" , err )
2665+ }
2666+ actualState = append (actualState , ps )
2667+ }
2668+
2669+ if d := cmp .Diff (expectedState , actualState ); d != "" {
2670+ t .Errorf ("Unexpected pipeline state: %s" , diff .PrintWantGot (d ))
2671+ }
2672+ }
2673+
26272674func TestResolvePipelineRun_PipelineTaskHasNoResources (t * testing.T ) {
26282675 pts := []v1.PipelineTask {{
26292676 Name : "mytask1" ,
@@ -2688,7 +2735,7 @@ func TestResolvePipelineRun_PipelineTaskHasPipelineRef(t *testing.T) {
26882735 if err == nil {
26892736 t .Errorf ("Error getting tasks for fake pipeline %s, expected an error but got nil." , p .ObjectMeta .Name )
26902737 }
2691- if ! strings .Contains (err .Error (), "does not support PipelineRef or PipelineSpec" ) {
2738+ if ! strings .Contains (err .Error (), "does not support PipelineRef, please use PipelineSpec, TaskRef or TaskSpec instead " ) {
26922739 t .Errorf ("Error getting tasks for fake pipeline %s: expected contains keyword but got %s" , p .ObjectMeta .Name , err )
26932740 }
26942741}
0 commit comments