@@ -581,14 +581,94 @@ func (s *RepositorySuite) TestPlainCloneWithRemoteName(c *C) {
581
581
c .Assert (remote , NotNil )
582
582
}
583
583
584
- func (s * RepositorySuite ) TestPlainCloneContext (c * C ) {
584
+ func (s * RepositorySuite ) TestPlainCloneContextWithProperParameters (c * C ) {
585
585
ctx , cancel := context .WithCancel (context .Background ())
586
586
cancel ()
587
587
588
- _ , err := PlainCloneContext (ctx , c .MkDir (), false , & CloneOptions {
588
+ r , err := PlainCloneContext (ctx , c .MkDir (), false , & CloneOptions {
589
589
URL : s .GetBasicLocalRepositoryURL (),
590
590
})
591
591
592
+ c .Assert (r , NotNil )
593
+ c .Assert (err , NotNil )
594
+ }
595
+
596
+ func (s * RepositorySuite ) TestPlainCloneContextNonExistentWithExistentDir (c * C ) {
597
+ ctx , cancel := context .WithCancel (context .Background ())
598
+ cancel ()
599
+
600
+ tmpDir := c .MkDir ()
601
+ repoDir := tmpDir
602
+
603
+ r , err := PlainCloneContext (ctx , repoDir , false , & CloneOptions {
604
+ URL : "incorrectOnPurpose" ,
605
+ })
606
+ c .Assert (r , NotNil )
607
+ c .Assert (err , NotNil )
608
+
609
+ _ , err = os .Stat (repoDir )
610
+ c .Assert (os .IsNotExist (err ), Equals , false )
611
+
612
+ names , err := ioutil .ReadDir (repoDir )
613
+ c .Assert (err , IsNil )
614
+ c .Assert (names , HasLen , 0 )
615
+ }
616
+
617
+ func (s * RepositorySuite ) TestPlainCloneContextNonExistentWithNonExistentDir (c * C ) {
618
+ ctx , cancel := context .WithCancel (context .Background ())
619
+ cancel ()
620
+
621
+ tmpDir := c .MkDir ()
622
+ repoDir := filepath .Join (tmpDir , "repoDir" )
623
+
624
+ r , err := PlainCloneContext (ctx , repoDir , false , & CloneOptions {
625
+ URL : "incorrectOnPurpose" ,
626
+ })
627
+ c .Assert (r , NotNil )
628
+ c .Assert (err , NotNil )
629
+
630
+ _ , err = os .Stat (repoDir )
631
+ c .Assert (os .IsNotExist (err ), Equals , true )
632
+ }
633
+
634
+ func (s * RepositorySuite ) TestPlainCloneContextNonExistentWithNotDir (c * C ) {
635
+ ctx , cancel := context .WithCancel (context .Background ())
636
+ cancel ()
637
+
638
+ tmpDir := c .MkDir ()
639
+ repoDir := filepath .Join (tmpDir , "repoDir" )
640
+ f , err := os .Create (repoDir )
641
+ c .Assert (err , IsNil )
642
+ c .Assert (f .Close (), IsNil )
643
+
644
+ r , err := PlainCloneContext (ctx , repoDir , false , & CloneOptions {
645
+ URL : "incorrectOnPurpose" ,
646
+ })
647
+ c .Assert (r , IsNil )
648
+ c .Assert (err , NotNil )
649
+
650
+ fi , err := os .Stat (repoDir )
651
+ c .Assert (err , IsNil )
652
+ c .Assert (fi .IsDir (), Equals , false )
653
+ }
654
+
655
+ func (s * RepositorySuite ) TestPlainCloneContextNonExistentWithNotEmptyDir (c * C ) {
656
+ ctx , cancel := context .WithCancel (context .Background ())
657
+ cancel ()
658
+
659
+ tmpDir := c .MkDir ()
660
+ repoDirPath := filepath .Join (tmpDir , "repoDir" )
661
+ err := os .Mkdir (repoDirPath , 0777 )
662
+ c .Assert (err , IsNil )
663
+
664
+ dummyFile := filepath .Join (repoDirPath , "dummyFile" )
665
+ err = ioutil .WriteFile (dummyFile , []byte (fmt .Sprint ("dummyContent" )), 0644 )
666
+ c .Assert (err , IsNil )
667
+
668
+ r , err := PlainCloneContext (ctx , repoDirPath , false , & CloneOptions {
669
+ URL : "incorrectOnPurpose" ,
670
+ })
671
+ c .Assert (r , IsNil )
592
672
c .Assert (err , NotNil )
593
673
}
594
674
@@ -2104,9 +2184,9 @@ func (s *RepositorySuite) TestResolveRevisionWithErrors(c *C) {
2104
2184
c .Assert (err , IsNil )
2105
2185
2106
2186
datas := map [string ]string {
2107
- "efs/heads/master~" : "reference not found" ,
2108
- "HEAD^3" : `Revision invalid : "3" found must be 0, 1 or 2 after "^"` ,
2109
- "HEAD^{/whatever}" : `No commit message match regexp : "whatever"` ,
2187
+ "efs/heads/master~" : "reference not found" ,
2188
+ "HEAD^3" : `Revision invalid : "3" found must be 0, 1 or 2 after "^"` ,
2189
+ "HEAD^{/whatever}" : `No commit message match regexp : "whatever"` ,
2110
2190
"4e1243bd22c66e76c2ba9eddc1f91394e57f9f83" : "reference not found" ,
2111
2191
"918c48b83bd081e863dbe1b80f8998f058cd8294" : `refname "918c48b83bd081e863dbe1b80f8998f058cd8294" is ambiguous` ,
2112
2192
}
0 commit comments