@@ -581,17 +581,55 @@ 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 )
592
593
c .Assert (err , NotNil )
593
594
}
594
595
596
+ func (s * RepositorySuite ) TestPlainCloneContextWithIncorrectRepo (c * C ) {
597
+ ctx , cancel := context .WithCancel (context .Background ())
598
+ cancel ()
599
+
600
+ tmpDir := c .MkDir ()
601
+ repoDir := filepath .Join (tmpDir , "repoDir" )
602
+ r , err := PlainCloneContext (ctx , repoDir , false , & CloneOptions {
603
+ URL : "incorrectOnPurpose" ,
604
+ })
605
+ c .Assert (r , IsNil )
606
+ c .Assert (err , NotNil )
607
+
608
+ _ , err = os .Stat (repoDir )
609
+ dirNotExist := os .IsNotExist (err )
610
+ c .Assert (dirNotExist , Equals , true )
611
+ }
612
+
613
+ func (s * RepositorySuite ) TestPlainCloneContextWithNotEmptyDir (c * C ) {
614
+ ctx , cancel := context .WithCancel (context .Background ())
615
+ cancel ()
616
+
617
+ tmpDir := c .MkDir ()
618
+ repoDirPath := filepath .Join (tmpDir , "repoDir" )
619
+ err := os .Mkdir (repoDirPath , 0777 )
620
+ c .Assert (err , IsNil )
621
+
622
+ dummyFile := filepath .Join (repoDirPath , "dummyFile" )
623
+ err = ioutil .WriteFile (dummyFile , []byte (fmt .Sprint ("dummyContent" )), 0644 )
624
+ c .Assert (err , IsNil )
625
+
626
+ r , err := PlainCloneContext (ctx , repoDirPath , false , & CloneOptions {
627
+ URL : "incorrectOnPurpose" ,
628
+ })
629
+ c .Assert (r , IsNil )
630
+ c .Assert (err , Equals , ErrDirNotEmpty )
631
+ }
632
+
595
633
func (s * RepositorySuite ) TestPlainCloneWithRecurseSubmodules (c * C ) {
596
634
if testing .Short () {
597
635
c .Skip ("skipping test in short mode." )
@@ -2104,9 +2142,9 @@ func (s *RepositorySuite) TestResolveRevisionWithErrors(c *C) {
2104
2142
c .Assert (err , IsNil )
2105
2143
2106
2144
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"` ,
2145
+ "efs/heads/master~" : "reference not found" ,
2146
+ "HEAD^3" : `Revision invalid : "3" found must be 0, 1 or 2 after "^"` ,
2147
+ "HEAD^{/whatever}" : `No commit message match regexp : "whatever"` ,
2110
2148
"4e1243bd22c66e76c2ba9eddc1f91394e57f9f83" : "reference not found" ,
2111
2149
"918c48b83bd081e863dbe1b80f8998f058cd8294" : `refname "918c48b83bd081e863dbe1b80f8998f058cd8294" is ambiguous` ,
2112
2150
}
0 commit comments