@@ -544,9 +544,12 @@ func TestRecordPipelineRunDurationCount(t *testing.T) {
544
544
func TestRecordRunningPipelineRunsCount (t * testing.T ) {
545
545
unregisterMetrics ()
546
546
547
- newPipelineRun := func (status corev1.ConditionStatus ) * v1.PipelineRun {
547
+ newPipelineRun := func (status corev1.ConditionStatus , specStatus v1. PipelineRunSpecStatus ) * v1.PipelineRun {
548
548
return & v1.PipelineRun {
549
549
ObjectMeta : metav1.ObjectMeta {Name : names .SimpleNameGenerator .RestrictLengthWithRandomSuffix ("pipelinerun-" )},
550
+ Spec : v1.PipelineRunSpec {
551
+ Status : specStatus ,
552
+ },
550
553
Status : v1.PipelineRunStatus {
551
554
Status : duckv1.Status {
552
555
Conditions : duckv1.Conditions {{
@@ -561,13 +564,18 @@ func TestRecordRunningPipelineRunsCount(t *testing.T) {
561
564
ctx , _ := ttesting .SetupFakeContext (t )
562
565
informer := fakepipelineruninformer .Get (ctx )
563
566
// 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 , "" ),
568
576
} {
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 )
571
579
}
572
580
}
573
581
0 commit comments