@@ -580,6 +580,73 @@ func TestGitSourceListVersionsNoHEAD(t *testing.T) {
580
580
}
581
581
}
582
582
583
+ func TestGitSourceListVersionsNoDupes (t * testing.T ) {
584
+ t .Parallel ()
585
+
586
+ // This test is slowish, skip it on -short
587
+ if testing .Short () {
588
+ t .Skip ("Skipping git source version fetching test in short mode" )
589
+ }
590
+ requiresBins (t , "git" )
591
+
592
+ cpath , err := ioutil .TempDir ("" , "smcache" )
593
+ if err != nil {
594
+ t .Errorf ("Failed to create temp dir: %s" , err )
595
+ }
596
+ defer func () {
597
+ if err := os .RemoveAll (cpath ); err != nil {
598
+ t .Errorf ("removeAll failed: %s" , err )
599
+ }
600
+ }()
601
+
602
+ n := "github.com/carolynvs/deptest-importers"
603
+ un := "https://" + n
604
+ u , err := url .Parse (un )
605
+ if err != nil {
606
+ t .Fatalf ("Error parsing URL %s: %s" , un , err )
607
+ }
608
+ mb := maybeGitSource {
609
+ url : u ,
610
+ }
611
+
612
+ ctx := context .Background ()
613
+ superv := newSupervisor (ctx )
614
+ src , state , err := mb .try (ctx , cpath , newMemoryCache (), superv )
615
+ if err != nil {
616
+ t .Fatalf ("Unexpected error while setting up gitSource for test repo: %s" , err )
617
+ }
618
+
619
+ wantstate := sourceIsSetUp | sourceExistsUpstream | sourceHasLatestVersionList
620
+ if state != wantstate {
621
+ t .Errorf ("Expected return state to be %v, got %v" , wantstate , state )
622
+ }
623
+
624
+ err = src .initLocal (ctx )
625
+ if err != nil {
626
+ t .Fatalf ("Error on cloning git repo: %s" , err )
627
+ }
628
+
629
+ pvlist , err := src .listVersions (ctx )
630
+ if err != nil {
631
+ t .Fatalf ("Unexpected error getting version pairs from git repo: %s" , err )
632
+ }
633
+
634
+ for i := range pvlist {
635
+ pv1 := pvlist [i ]
636
+ uv1 := pv1 .Unpair ()
637
+ for j := range pvlist {
638
+ if i == j {
639
+ continue
640
+ }
641
+ pv2 := pvlist [j ]
642
+ uv2 := pv2 .Unpair ()
643
+ if uv1 == uv2 {
644
+ t .Errorf ("duplicate version pair mapping from %#v to both %q and %q" , uv1 , pv1 .Revision (), pv2 .Revision ())
645
+ }
646
+ }
647
+ }
648
+ }
649
+
583
650
func Test_bzrSource_exportRevisionTo_removeVcsFiles (t * testing.T ) {
584
651
t .Parallel ()
585
652
0 commit comments