diff options
author | Máximo Cuadros <mcuadros@gmail.com> | 2017-11-21 11:27:37 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-11-21 11:27:37 +0100 |
commit | 97fb5e93083fbe4ea02078312ae2cbca3b145ab1 (patch) | |
tree | 4ce4c4b5616edb713ea2bc0ebbf485376933cc91 /plumbing/transport/common_test.go | |
parent | dd81bc9156afb8102dd4c082a81bdb285d2e0a4b (diff) | |
parent | 5eb1c562e7deb4191cb160af91a864fb783c1041 (diff) | |
download | go-git-97fb5e93083fbe4ea02078312ae2cbca3b145ab1.tar.gz |
Merge pull request #650 from mcuadros/endpoint
transport: converts Endpoint interface into a struct
Diffstat (limited to 'plumbing/transport/common_test.go')
-rw-r--r-- | plumbing/transport/common_test.go | 149 |
1 files changed, 84 insertions, 65 deletions
diff --git a/plumbing/transport/common_test.go b/plumbing/transport/common_test.go index 52759e6..4203ce9 100644 --- a/plumbing/transport/common_test.go +++ b/plumbing/transport/common_test.go @@ -17,120 +17,139 @@ var _ = Suite(&SuiteCommon{}) 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.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) TestNewEndpointPorts(c *C) { + e, err := NewEndpoint("http://git:pass@github.com:8080/user/repository.git?foo#bar") + c.Assert(err, IsNil) + c.Assert(e.String(), Equals, "http://git:pass@github.com:8080/user/repository.git?foo#bar") + + e, err = NewEndpoint("https://git:pass@github.com:443/user/repository.git?foo#bar") + c.Assert(err, IsNil) + c.Assert(e.String(), Equals, "https://git:pass@github.com/user/repository.git?foo#bar") + + e, err = NewEndpoint("ssh://git:pass@github.com:22/user/repository.git?foo#bar") + c.Assert(err, IsNil) + c.Assert(e.String(), Equals, "ssh://git:pass@github.com/user/repository.git?foo#bar") + + e, err = NewEndpoint("git://github.com:9418/user/repository.git?foo#bar") + c.Assert(err, IsNil) + c.Assert(e.String(), Equals, "git://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.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.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.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.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") + 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, "ssh://git@github.com/user/repository.git") } func (s *SuiteCommon) TestNewEndpointSCPLikeWithPort(c *C) { e, err := NewEndpoint("git@github.com:9999/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, 9999) - c.Assert(e.Path(), Equals, "user/repository.git") - c.Assert(e.String(), Equals, "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, 9999) + c.Assert(e.Path, Equals, "user/repository.git") + c.Assert(e.String(), Equals, "ssh://git@github.com:9999/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") + 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) 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") + 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) 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") + 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, "file://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.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") } |