@@ -555,6 +555,139 @@ def shorten_rows rows
555
555
end
556
556
end
557
557
558
+ describe "find with global latest and tag specified" do
559
+ subject { shorten_rows ( Repository . new . find ( selectors , options ) ) }
560
+
561
+ context "with one consumer/version and latest tag specified for all the other pacticipants" do
562
+ before do
563
+ td . create_pact_with_hierarchy ( "A" , "1" , "B" )
564
+ . create_verification ( provider_version : "1" )
565
+ . create_verification ( provider_version : "2" , number : 2 )
566
+ . use_provider_version ( "1" )
567
+ . create_provider_version_tag ( "prod" )
568
+ . create_provider ( "C" )
569
+ . create_pact
570
+ . create_verification ( provider_version : "3" )
571
+ . use_provider_version ( "3" )
572
+ . create_provider_version_tag ( "prod" )
573
+ . create_verification ( provider_version : "4" , number : 2 )
574
+ end
575
+
576
+ let ( :selectors ) { build_selectors ( 'A' => '1' ) }
577
+ let ( :options ) { { tag : 'prod' , latest : true } }
578
+
579
+ it "finds the matrix for the latest tagged versions of each of the other other pacticipants" do
580
+ expect ( subject ) . to include "A1 B1 n1"
581
+ expect ( subject ) . to include "A1 C3 n1"
582
+ expect ( subject . size ) . to eq 2
583
+ end
584
+ end
585
+
586
+ context "with one consumer/version and latest specified for all the other pacticipants" do
587
+ before do
588
+ td . create_pact_with_hierarchy ( "A" , "1" , "B" )
589
+ . create_verification ( provider_version : "1" )
590
+ . create_verification ( provider_version : "2" , number : 2 )
591
+ . use_provider_version ( "1" )
592
+ . create_provider ( "C" )
593
+ . create_pact
594
+ . create_verification ( provider_version : "3" )
595
+ . create_verification ( provider_version : "4" , number : 2 )
596
+ end
597
+
598
+ let ( :selectors ) { build_selectors ( 'A' => '1' ) }
599
+ let ( :options ) { { latest : true } }
600
+
601
+ it "finds the matrix for the latest tagged versions of each of the other other pacticipants" do
602
+ expect ( subject ) . to include "A1 B2 n2"
603
+ expect ( subject ) . to include "A1 C4 n2"
604
+ expect ( subject . size ) . to eq 2
605
+ end
606
+ end
607
+
608
+ context "with one pacticipant without a version and latest tag specified for all the other pacticipants" do
609
+ before do
610
+ td . create_pact_with_hierarchy ( "A" , "1" , "B" )
611
+ . create_verification ( provider_version : "1" )
612
+ . create_verification ( provider_version : "2" , number : 2 )
613
+ . use_provider_version ( "1" )
614
+ . create_provider_version_tag ( "prod" )
615
+ . create_provider ( "C" )
616
+ . create_pact
617
+ . create_verification ( provider_version : "3" )
618
+ . use_provider_version ( "3" )
619
+ . create_provider_version_tag ( "prod" )
620
+ . create_verification ( provider_version : "4" , number : 2 )
621
+ . create_consumer_version ( "2" )
622
+ . create_pact
623
+ end
624
+
625
+ let ( :selectors ) { build_selectors ( 'A' => nil ) }
626
+ let ( :options ) { { tag : 'prod' , latest : true } }
627
+
628
+ it "finds the matrix for the latest tagged versions of each of the other other pacticipants" do
629
+ expect ( subject ) . to include "A1 B1 n1"
630
+ expect ( subject ) . to include "A1 C3 n1"
631
+ expect ( subject ) . to include "A2 C? n?"
632
+ expect ( subject . size ) . to eq 3
633
+ end
634
+ end
635
+
636
+ context "with one pacticipant/version that is both a consumer and provider and latest tag specified for all the other pacticipants" do
637
+ before do
638
+ td . create_pact_with_hierarchy ( "A" , "1" , "B" )
639
+ . create_consumer_version_tag ( "prod" )
640
+ . create_verification ( provider_version : "1" )
641
+ . use_provider_version ( "1" )
642
+ . use_consumer ( "B" )
643
+ . use_consumer_version ( "1" )
644
+ . create_provider ( "C" )
645
+ . create_pact
646
+ . create_verification ( provider_version : "3" )
647
+ . use_provider_version ( "3" )
648
+ . create_provider_version_tag ( "prod" )
649
+ . create_verification ( provider_version : "4" , number : 2 )
650
+ end
651
+
652
+ let ( :selectors ) { build_selectors ( 'B' => '1' ) }
653
+ let ( :options ) { { tag : 'prod' , latest : true } }
654
+
655
+ it "finds the matrix for the latest tagged versions of each of the other other pacticipants" do
656
+ expect ( subject ) . to include "A1 B1 n1"
657
+ expect ( subject ) . to include "B1 C3 n1"
658
+ expect ( subject . size ) . to eq 2
659
+ end
660
+ end
661
+
662
+ context "with one pacticipant/latest tag and latest tag specified for all the other pacticipants" do
663
+ before do
664
+ td . create_pact_with_hierarchy ( "A" , "1" , "B" )
665
+ . create_consumer_version_tag ( "dev" )
666
+ . create_verification ( provider_version : "1" )
667
+ . use_provider_version ( "1" )
668
+ . create_provider_version_tag ( "prod" )
669
+ . create_provider ( "C" )
670
+ . create_pact
671
+ . create_verification ( provider_version : "3" )
672
+ . use_provider_version ( "3" )
673
+ . create_provider_version_tag ( "prod" )
674
+ . create_verification ( provider_version : "4" , number : 2 )
675
+ end
676
+
677
+ let ( :selectors ) { [ { pacticipant_name : 'A' , latest : true , tag : 'dev' } ] }
678
+ let ( :options ) { { tag : 'prod' , latest : true } }
679
+
680
+ it "finds the matrix for the latest tagged versions of each of the other other pacticipants" do
681
+ expect ( subject ) . to include "A1 B1 n1"
682
+ expect ( subject ) . to include "A1 C3 n1"
683
+ expect ( subject ) . to_not include "A1 C4 n2"
684
+ expect ( subject . size ) . to eq 2
685
+ end
686
+ end
687
+
688
+
689
+ end
690
+
558
691
describe "#find_for_consumer_and_provider" do
559
692
before do
560
693
TestDataBuilder . new
0 commit comments