@@ -1891,6 +1891,85 @@ func TestReconcileWithTaskResults(t *testing.T) {
18911891 }
18921892}
18931893
1894+ func TestReconcileWithTaskResultsEmbeddedNoneStarted (t * testing.T ) {
1895+ names .TestingSeed ()
1896+ prs := []* v1alpha1.PipelineRun {tb .PipelineRun ("test-pipeline-run-different-service-accs" , tb .PipelineRunNamespace ("foo" ),
1897+ tb .PipelineRunSpec ("test-pipeline" ,
1898+ tb .PipelineRunPipelineSpec (
1899+ tb .PipelineParamSpec ("foo" , v1alpha1 .ParamTypeString ),
1900+ tb .PipelineTask ("a-task" , "a-task" ),
1901+ tb .PipelineTask ("b-task" , "b-task" ,
1902+ tb .PipelineTaskParam ("bParam" , "$(params.foo)/baz@$(tasks.a-task.results.A_RESULT)" ),
1903+ ),
1904+ ),
1905+ tb .PipelineRunParam ("foo" , "bar" ),
1906+ tb .PipelineRunServiceAccountName ("test-sa-0" ),
1907+ ),
1908+ )}
1909+ ts := []* v1alpha1.Task {
1910+ tb .Task ("a-task" , tb .TaskNamespace ("foo" ),
1911+ tb .TaskSpec (
1912+ tb .TaskResults ("A_RESULT" , "" ),
1913+ ),
1914+ ),
1915+ tb .Task ("b-task" , tb .TaskNamespace ("foo" ),
1916+ tb .TaskSpec (
1917+ tb .TaskInputs (tb .InputsParamSpec ("bParam" , v1alpha1 .ParamTypeString )),
1918+ ),
1919+ ),
1920+ }
1921+ d := test.Data {
1922+ PipelineRuns : prs ,
1923+ Tasks : ts ,
1924+ }
1925+ testAssets , cancel := getPipelineRunController (t , d )
1926+ defer cancel ()
1927+ c := testAssets .Controller
1928+ clients := testAssets .Clients
1929+ err := c .Reconciler .Reconcile (context .Background (), "foo/test-pipeline-run-different-service-accs" )
1930+ if err != nil {
1931+ t .Errorf ("Did not expect to see error when reconciling completed PipelineRun but saw %s" , err )
1932+ }
1933+ // Check that the PipelineRun was reconciled correctly
1934+ reconciledRun , err := clients .Pipeline .TektonV1alpha1 ().PipelineRuns ("foo" ).Get ("test-pipeline-run-different-service-accs" , metav1.GetOptions {})
1935+ if err != nil {
1936+ t .Fatalf ("Somehow had error getting completed reconciled run out of fake client: %s" , err )
1937+ }
1938+
1939+ if ! reconciledRun .Status .GetCondition (apis .ConditionSucceeded ).IsUnknown () {
1940+ t .Errorf ("Expected PipelineRun to be running, but condition status is %s" , reconciledRun .Status .GetCondition (apis .ConditionSucceeded ))
1941+ }
1942+
1943+ // Since b-task is dependent on a-task, via the results, only a-task should run
1944+ expectedTaskRunName := "test-pipeline-run-different-service-accs-a-task-9l9zj"
1945+ expectedTaskRun := tb .TaskRun (expectedTaskRunName ,
1946+ tb .TaskRunNamespace ("foo" ),
1947+ tb .TaskRunOwnerReference ("PipelineRun" , "test-pipeline-run-different-service-accs" ,
1948+ tb .OwnerReferenceAPIVersion ("tekton.dev/v1alpha1" ),
1949+ tb .Controller , tb .BlockOwnerDeletion ,
1950+ ),
1951+ tb .TaskRunLabel ("tekton.dev/pipeline" , "test-pipeline-run-different-service-accs" ),
1952+ tb .TaskRunLabel ("tekton.dev/pipelineRun" , "test-pipeline-run-different-service-accs" ),
1953+ tb .TaskRunLabel ("tekton.dev/pipelineTask" , "a-task" ),
1954+ tb .TaskRunSpec (
1955+ tb .TaskRunTaskRef ("a-task" , tb .TaskRefKind (v1beta1 .NamespacedTaskKind )),
1956+ tb .TaskRunServiceAccountName ("test-sa-0" ),
1957+ ),
1958+ )
1959+ // Check that the expected TaskRun was created (only)
1960+ actual , err := clients .Pipeline .TektonV1alpha1 ().TaskRuns ("foo" ).List (metav1.ListOptions {})
1961+ if err != nil {
1962+ t .Fatalf ("Failure to list TaskRun's %s" , err )
1963+ }
1964+ if len (actual .Items ) != 1 {
1965+ t .Fatalf ("Expected 1 TaskRuns got %d" , len (actual .Items ))
1966+ }
1967+ actualTaskRun := actual .Items [0 ]
1968+ if d := cmp .Diff (expectedTaskRun , & actualTaskRun ); d != "" {
1969+ t .Errorf ("expected to see TaskRun %v created. Diff (-want, +got): %s" , expectedTaskRun , d )
1970+ }
1971+ }
1972+
18941973func TestReconcileWithPipelineResults (t * testing.T ) {
18951974 names .TestingSeed ()
18961975 ps := []* v1alpha1.Pipeline {tb .Pipeline ("test-pipeline" , tb .PipelineNamespace ("foo" ), tb .PipelineSpec (
0 commit comments