aboutsummaryrefslogtreecommitdiffstats
path: root/plumbing/transport/common_test.go
diff options
context:
space:
mode:
authorMáximo Cuadros <mcuadros@gmail.com>2017-05-04 10:17:15 +0200
committerMáximo Cuadros <mcuadros@gmail.com>2017-05-04 10:17:15 +0200
commitb8b61e74469e0d2662e7d690eee14893f91fe259 (patch)
tree1933fe53200d98ad2c557d034609408641ce2900 /plumbing/transport/common_test.go
parent40fa5882a2c73f8c075403b7ec85870f04deda07 (diff)
parente80cdbabb92a1ec35ffad536f52d3ff04b548fd1 (diff)
downloadgo-git-b8b61e74469e0d2662e7d690eee14893f91fe259.tar.gz
Merge branch 'master' of github.com:src-d/go-git into commit
Diffstat (limited to 'plumbing/transport/common_test.go')
-rw-r--r--plumbing/transport/common_test.go108
1 files changed, 102 insertions, 6 deletions
diff --git a/plumbing/transport/common_test.go b/plumbing/transport/common_test.go
index e9a5efa..ec617bd 100644
--- a/plumbing/transport/common_test.go
+++ b/plumbing/transport/common_test.go
@@ -14,22 +14,118 @@ type SuiteCommon struct{}
var _ = Suite(&SuiteCommon{})
-func (s *SuiteCommon) TestNewEndpoint(c *C) {
+func (s *SuiteCommon) TestNewEndpointHTTP(c *C) {
+ e, err := NewEndpoint("http://git:pass@github.com/user/repository.git?foo#bar")
+ c.Assert(err, IsNil)
+ c.Assert(e.Protocol(), Equals, "http")
+ c.Assert(e.User(), Equals, "git")
+ c.Assert(e.Password(), Equals, "pass")
+ c.Assert(e.Host(), Equals, "github.com")
+ c.Assert(e.Port(), Equals, 0)
+ c.Assert(e.Path(), Equals, "/user/repository.git?foo#bar")
+ c.Assert(e.String(), Equals, "http://git:pass@github.com/user/repository.git?foo#bar")
+}
+
+func (s *SuiteCommon) TestNewEndpointSSH(c *C) {
e, err := NewEndpoint("ssh://git@github.com/user/repository.git")
c.Assert(err, IsNil)
+ c.Assert(e.Protocol(), Equals, "ssh")
+ c.Assert(e.User(), Equals, "git")
+ c.Assert(e.Password(), Equals, "")
+ c.Assert(e.Host(), Equals, "github.com")
+ c.Assert(e.Port(), Equals, 0)
+ c.Assert(e.Path(), Equals, "/user/repository.git")
c.Assert(e.String(), Equals, "ssh://git@github.com/user/repository.git")
}
+func (s *SuiteCommon) TestNewEndpointSSHNoUser(c *C) {
+ e, err := NewEndpoint("ssh://github.com/user/repository.git")
+ c.Assert(err, IsNil)
+ c.Assert(e.Protocol(), Equals, "ssh")
+ c.Assert(e.User(), Equals, "")
+ c.Assert(e.Password(), Equals, "")
+ c.Assert(e.Host(), Equals, "github.com")
+ c.Assert(e.Port(), Equals, 0)
+ c.Assert(e.Path(), Equals, "/user/repository.git")
+ c.Assert(e.String(), Equals, "ssh://github.com/user/repository.git")
+}
+
+func (s *SuiteCommon) TestNewEndpointSSHWithPort(c *C) {
+ e, err := NewEndpoint("ssh://git@github.com:777/user/repository.git")
+ c.Assert(err, IsNil)
+ c.Assert(e.Protocol(), Equals, "ssh")
+ c.Assert(e.User(), Equals, "git")
+ c.Assert(e.Password(), Equals, "")
+ c.Assert(e.Host(), Equals, "github.com")
+ c.Assert(e.Port(), Equals, 777)
+ c.Assert(e.Path(), Equals, "/user/repository.git")
+ c.Assert(e.String(), Equals, "ssh://git@github.com:777/user/repository.git")
+}
+
func (s *SuiteCommon) TestNewEndpointSCPLike(c *C) {
e, err := NewEndpoint("git@github.com:user/repository.git")
c.Assert(err, IsNil)
- c.Assert(e.String(), Equals, "ssh://git@github.com/user/repository.git")
+ c.Assert(e.Protocol(), Equals, "ssh")
+ c.Assert(e.User(), Equals, "git")
+ c.Assert(e.Password(), Equals, "")
+ c.Assert(e.Host(), Equals, "github.com")
+ c.Assert(e.Port(), Equals, 22)
+ c.Assert(e.Path(), Equals, "user/repository.git")
+ c.Assert(e.String(), Equals, "git@github.com:user/repository.git")
+}
+
+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) TestNewEndpointWrongForgat(c *C) {
- e, err := NewEndpoint("foo")
- c.Assert(err, Not(IsNil))
- c.Assert(e.Host, Equals, "")
+func (s *SuiteCommon) TestNewEndpointInvalidURL(c *C) {
+ e, err := NewEndpoint("http://\\")
+ c.Assert(err, NotNil)
+ c.Assert(e, IsNil)
}
func (s *SuiteCommon) TestFilterUnsupportedCapabilities(c *C) {