// TestUpdateTaskRunsState runs "getTaskRunsStatus" and verifies how it updates a PipelineRun status
// from a TaskRun associated to the PipelineRun
TestUpdateTaskRunsState runs "getTaskRunsStatus" and verifies how it updates a PipelineRun status
from a TaskRun associated to the PipelineRun
// TestUpdateTaskRunsState runs " getTaskRunsStatus " and verifies how it updates a PipelineRun status // from a TaskRun associated to the PipelineRun
func TestUpdateTaskRunsState(t *testing.T) {
	pr := parse.MustParsePipelineRun(t, `
metadata:
  name: test-pipeline-run
  namespace: foo
spec:
  pipelineRef:
    name: test-pipeline
`)
	pipelineTask := v1beta1.PipelineTask{
		Name: "unit-test-1",
		WhenExpressions: []v1beta1.WhenExpression{{
			Input:    "foo",
			Operator: selection.In,
			Values:   []string{"foo", "bar"},
		}},
		TaskRef: &v1beta1.TaskRef{Name: "unit-test-task"},
	}
	task := parse.MustParseTask(t, fmt.Sprintf(`
metadata:
  name: unit-test-task
  namespace: foo
spec:
  resources:
    inputs:
      - name: workspace
        type: %s
`, resourcev1alpha1.PipelineResourceTypeGit))
	taskrun := parse.MustParseTaskRun(t, fmt.Sprintf(`
metadata:
  name: test-pipeline-run-success-unit-test-1
  namespace: foo
spec:
  taskRef:
    name: unit-test-task
  serviceAccountName: test-sa
  timeout: 1h0m0s
status:
  conditions:
    - type: Succeeded
  steps:
    - container:
      terminated:
        exitCode: 0
`))
	state := PipelineRunState{{
		PipelineTask: &pipelineTask,
		TaskRunName:  "test-pipeline-run-success-unit-test-1",
		TaskRun:      taskrun,
		ResolvedTaskResources: &resources.ResolvedTaskResources{
			TaskSpec: &task.Spec,
		},
	}}
	pr.Status.InitializeConditions(testClock)
	status := state.GetTaskRunsStatus(pr)
	expectedPipelineRunStatus := parse.MustParsePipelineRun(t, `
metadata:
  name: pipelinerun
  namespace: foo
status:
  taskRuns:
    test-pipeline-run-success-unit-test-1:
      pipelineTaskName: unit-test-1
      status:
        conditions:
          - type: Succeeded
        steps:
          - container:
            terminated:
              exitCode: 0
      whenExpressions:
        - input: foo
          operator: in
          values: ["foo", "bar"]
`)
	if d := cmp.Diff(expectedPipelineRunStatus.Status.TaskRuns, status); d != "" {
		t.Fatalf("Expected PipelineRun status to match TaskRun(s) status, but got a mismatch: %s", diff.PrintWantGot(d))
	}
}
func TestUpdateTaskRunsState ( t * testing . T ) { pr := parse . MustParsePipelineRun ( t , `
metadata:
  name: test-pipeline-run
  namespace: foo
spec:
  pipelineRef:
    name: test-pipeline
` ) pipelineTask := v1beta1 . PipelineTask { Name : " " , WhenExpressions : [ ] v1beta1 . WhenExpression { { Input : " " , Operator : selection . In , Values : [ ] string { " " , " " } , } } , TaskRef : & v1beta1 . TaskRef { Name : " " } , } task := parse . MustParseTask ( t , fmt . Sprintf ( `
metadata:
  name: unit-test-task
  namespace: foo
spec:
  resources:
    inputs:
      - name: workspace
        type: %s
` , resourcev1alpha1 . PipelineResourceTypeGit ) ) taskrun := parse . MustParseTaskRun ( t , fmt . Sprintf ( `
metadata:
  name: test-pipeline-run-success-unit-test-1
  namespace: foo
spec:
  taskRef:
    name: unit-test-task
  serviceAccountName: test-sa
  timeout: 1h0m0s
status:
  conditions:
    - type: Succeeded
  steps:
    - container:
      terminated:
        exitCode: 0
` ) ) state := PipelineRunState { { PipelineTask : & pipelineTask , TaskRunName : " " , TaskRun : taskrun , ResolvedTaskResources : & resources . ResolvedTaskResources { TaskSpec : & task . Spec , } , } } pr . Status . InitializeConditions ( testClock ) status := state . GetTaskRunsStatus ( pr ) expectedPipelineRunStatus := parse . MustParsePipelineRun ( t , `
metadata:
  name: pipelinerun
  namespace: foo
status:
  taskRuns:
    test-pipeline-run-success-unit-test-1:
      pipelineTaskName: unit-test-1
      status:
        conditions:
          - type: Succeeded
        steps:
          - container:
            terminated:
              exitCode: 0
      whenExpressions:
        - input: foo
          operator: in
          values: ["foo", "bar"]
` ) if d := cmp . Diff ( expectedPipelineRunStatus . Status . TaskRuns , status ) ; d != " " { t . Fatalf ( " " , diff . PrintWantGot ( d ) ) } }
TestUpdateTaskRunsState runs "getTaskRunsStatus" and verifies how it updates a PipelineRun status
from a TaskRun associated to the PipelineRun
TestUpdateTaskRunsState runs " getTaskRunsStatus " and verifies how it updates a PipelineRun status from a TaskRun associated to the PipelineRun