@@ -544,9 +544,12 @@ func TestRecordPipelineRunDurationCount(t *testing.T) {
544544func TestRecordRunningPipelineRunsCount (t * testing.T ) {
545545 unregisterMetrics ()
546546
547- newPipelineRun := func (status corev1.ConditionStatus ) * v1.PipelineRun {
547+ newPipelineRun := func (status corev1.ConditionStatus , specStatus v1. PipelineRunSpecStatus ) * v1.PipelineRun {
548548 return & v1.PipelineRun {
549549 ObjectMeta : metav1.ObjectMeta {Name : names .SimpleNameGenerator .RestrictLengthWithRandomSuffix ("pipelinerun-" )},
550+ Spec : v1.PipelineRunSpec {
551+ Status : specStatus ,
552+ },
550553 Status : v1.PipelineRunStatus {
551554 Status : duckv1.Status {
552555 Conditions : duckv1.Conditions {{
@@ -561,13 +564,18 @@ func TestRecordRunningPipelineRunsCount(t *testing.T) {
561564 ctx , _ := ttesting .SetupFakeContext (t )
562565 informer := fakepipelineruninformer .Get (ctx )
563566 // Add N randomly-named PipelineRuns with differently-succeeded statuses.
564- for _ , tr := range []* v1.PipelineRun {
565- newPipelineRun (corev1 .ConditionTrue ),
566- newPipelineRun (corev1 .ConditionUnknown ),
567- newPipelineRun (corev1 .ConditionFalse ),
567+ for _ , pr := range []* v1.PipelineRun {
568+ // Completed PipelineRun - should NOT be counted as running
569+ newPipelineRun (corev1 .ConditionTrue , "" ),
570+ // Actually running PipelineRun - should be counted as running
571+ newPipelineRun (corev1 .ConditionUnknown , "" ),
572+ // Pending PipelineRun - should NOT be counted as running
573+ newPipelineRun (corev1 .ConditionUnknown , v1 .PipelineRunSpecStatusPending ),
574+ // Failed PipelineRun - should NOT be counted as running
575+ newPipelineRun (corev1 .ConditionFalse , "" ),
568576 } {
569- if err := informer .Informer ().GetIndexer ().Add (tr ); err != nil {
570- t .Fatalf ("Adding TaskRun to informer: %v" , err )
577+ if err := informer .Informer ().GetIndexer ().Add (pr ); err != nil {
578+ t .Fatalf ("Adding PipelineRun to informer: %v" , err )
571579 }
572580 }
573581
0 commit comments