// TestUpdateRunsState runs "getRunsStatus" and verifies how it updates a PipelineRun status
// from a Run associated to the PipelineRun
TestUpdateRunsState runs "getRunsStatus" and verifies how it updates a PipelineRun status
from a Run associated to the PipelineRun
// TestUpdateRunsState runs " getRunsStatus " and verifies how it updates a PipelineRun status // from a Run associated to the PipelineRun
func TestUpdateRunsState(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{
			APIVersion: "example.dev/v0",
			Kind:       "Example",
			Name:       "unit-test-run",
		},
	}
	run := parse.MustParseRun(t, fmt.Sprintf(`
metadata:
  name: unit-test-run
  namespace: foo
status:
  conditions:
    - type: Succeeded
      status: "True"
`))
	state := PipelineRunState{{
		PipelineTask: &pipelineTask,
		CustomTask:   true,
		RunName:      "test-pipeline-run-success-unit-test-1",
		Run:          run,
	}}
	pr.Status.InitializeConditions(testClock)
	status := state.GetRunsStatus(pr)
	expectedPipelineRunStatus := parse.MustParsePipelineRun(t, `
metadata:
  name: pipelinerun
  namespace: foo
status:
  runs:
    test-pipeline-run-success-unit-test-1:
      pipelineTaskName: unit-test-1
      status:
        conditions:
          - type: Succeeded
            status: "True"
        steps:
          - container:
            terminated:
              exitCode: 0
      whenExpressions:
        - input: foo
          operator: in
          values: ["foo", "bar"]
`)
	if d := cmp.Diff(expectedPipelineRunStatus.Status.Runs, status); d != "" {
		t.Fatalf("Expected PipelineRun status to match Run(s) status, but got a mismatch: %s", diff.PrintWantGot(d))
	}
}
func TestUpdateRunsState ( 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 { APIVersion : " " , Kind : " " , Name : " " , } , } run := parse . MustParseRun ( t , fmt . Sprintf ( `
metadata:
  name: unit-test-run
  namespace: foo
status:
  conditions:
    - type: Succeeded
      status: "True"
` ) ) state := PipelineRunState { { PipelineTask : & pipelineTask , CustomTask : true , RunName : " " , Run : run , } } pr . Status . InitializeConditions ( testClock ) status := state . GetRunsStatus ( pr ) expectedPipelineRunStatus := parse . MustParsePipelineRun ( t , `
metadata:
  name: pipelinerun
  namespace: foo
status:
  runs:
    test-pipeline-run-success-unit-test-1:
      pipelineTaskName: unit-test-1
      status:
        conditions:
          - type: Succeeded
            status: "True"
        steps:
          - container:
            terminated:
              exitCode: 0
      whenExpressions:
        - input: foo
          operator: in
          values: ["foo", "bar"]
` ) if d := cmp . Diff ( expectedPipelineRunStatus . Status . Runs , status ) ; d != " " { t . Fatalf ( " " , diff . PrintWantGot ( d ) ) } }
TestUpdateRunsState runs "getRunsStatus" and verifies how it updates a PipelineRun status
from a Run associated to the PipelineRun
TestUpdateRunsState runs " getRunsStatus " and verifies how it updates a PipelineRun status from a Run associated to the PipelineRun