aboutsummaryrefslogtreecommitdiffstats
path: root/plumbing/transport/common_test.go
diff options
context:
space:
mode:
authorSantiago M. Mola <santi@mola.io>2017-04-28 15:20:51 +0200
committerSantiago M. Mola <santi@mola.io>2017-04-28 16:33:31 +0200
commit4a670e130804d630fa056e4a60101698dc7a9af1 (patch)
tree289fed4a798d9e3c7bdc633970109d8a7a856737 /plumbing/transport/common_test.go
parent727bf94da8e3cebd3ff467d30425b12d671fbca7 (diff)
downloadgo-git-4a670e130804d630fa056e4a60101698dc7a9af1.tar.gz
do not convert local paths to URL
* Do not convert local paths to URLs, just keep them as they are. * This way we add support for Windows without taking care of Windows path-to-URL conversion.
Diffstat (limited to 'plumbing/transport/common_test.go')
-rw-r--r--plumbing/transport/common_test.go52
1 files changed, 50 insertions, 2 deletions
diff --git a/plumbing/transport/common_test.go b/plumbing/transport/common_test.go
index ce41045..ec617bd 100644
--- a/plumbing/transport/common_test.go
+++ b/plumbing/transport/common_test.go
@@ -74,8 +74,56 @@ func (s *SuiteCommon) TestNewEndpointSCPLike(c *C) {
c.Assert(e.String(), Equals, "git@github.com:user/repository.git")
}
-func (s *SuiteCommon) TestNewEndpointWrongForgat(c *C) {
- e, err := NewEndpoint("foo")
+func (s *SuiteCommon) TestNewEndpointFileAbs(c *C) {
+ e, err := NewEndpoint("/foo.git")
+ c.Assert(err, IsNil)
+ c.Assert(e.Protocol(), Equals, "file")
+ c.Assert(e.User(), Equals, "")
+ c.Assert(e.Password(), Equals, "")
+ c.Assert(e.Host(), Equals, "")
+ c.Assert(e.Port(), Equals, 0)
+ c.Assert(e.Path(), Equals, "/foo.git")
+ c.Assert(e.String(), Equals, "/foo.git")
+}
+
+func (s *SuiteCommon) TestNewEndpointFileRel(c *C) {
+ e, err := NewEndpoint("foo.git")
+ c.Assert(err, IsNil)
+ c.Assert(e.Protocol(), Equals, "file")
+ c.Assert(e.User(), Equals, "")
+ c.Assert(e.Password(), Equals, "")
+ c.Assert(e.Host(), Equals, "")
+ c.Assert(e.Port(), Equals, 0)
+ c.Assert(e.Path(), Equals, "foo.git")
+ c.Assert(e.String(), Equals, "foo.git")
+}
+
+func (s *SuiteCommon) TestNewEndpointFileWindows(c *C) {
+ e, err := NewEndpoint("C:\\foo.git")
+ c.Assert(err, IsNil)
+ c.Assert(e.Protocol(), Equals, "file")
+ c.Assert(e.User(), Equals, "")
+ c.Assert(e.Password(), Equals, "")
+ c.Assert(e.Host(), Equals, "")
+ c.Assert(e.Port(), Equals, 0)
+ c.Assert(e.Path(), Equals, "C:\\foo.git")
+ c.Assert(e.String(), Equals, "C:\\foo.git")
+}
+
+func (s *SuiteCommon) TestNewEndpointFileURL(c *C) {
+ e, err := NewEndpoint("file:///foo.git")
+ c.Assert(err, IsNil)
+ c.Assert(e.Protocol(), Equals, "file")
+ c.Assert(e.User(), Equals, "")
+ c.Assert(e.Password(), Equals, "")
+ c.Assert(e.Host(), Equals, "")
+ c.Assert(e.Port(), Equals, 0)
+ c.Assert(e.Path(), Equals, "/foo.git")
+ c.Assert(e.String(), Equals, "file:///foo.git")
+}
+
+func (s *SuiteCommon) TestNewEndpointInvalidURL(c *C) {
+ e, err := NewEndpoint("http://\\")
c.Assert(err, NotNil)
c.Assert(e, IsNil)
}