diff options
author | Máximo Cuadros <mcuadros@gmail.com> | 2016-11-08 23:46:38 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-11-08 23:46:38 +0100 |
commit | ac095bb12c4d29722b60ba9f20590fa7cfa6bc7d (patch) | |
tree | 223f36f336ba3414b1e45cac8af6c4744a5d7ef6 /plumbing/client/common_test.go | |
parent | e523701393598f4fa241dd407af9ff8925507a1a (diff) | |
download | go-git-ac095bb12c4d29722b60ba9f20590fa7cfa6bc7d.tar.gz |
new plumbing package (#118)
* plumbing: now core was renamed to core, and formats and clients moved inside
Diffstat (limited to 'plumbing/client/common_test.go')
-rw-r--r-- | plumbing/client/common_test.go | 85 |
1 files changed, 85 insertions, 0 deletions
diff --git a/plumbing/client/common_test.go b/plumbing/client/common_test.go new file mode 100644 index 0000000..058c4d3 --- /dev/null +++ b/plumbing/client/common_test.go @@ -0,0 +1,85 @@ +package clients + +import ( + "fmt" + "io" + "testing" + + "gopkg.in/src-d/go-git.v4/plumbing/client/common" + + . "gopkg.in/check.v1" +) + +func Test(t *testing.T) { TestingT(t) } + +type SuiteCommon struct{} + +var _ = Suite(&SuiteCommon{}) + +func (s *SuiteCommon) TestNewGitUploadPackServiceHTTP(c *C) { + e, err := common.NewEndpoint("http://github.com/src-d/go-git") + c.Assert(err, IsNil) + + output, err := NewGitUploadPackService(e) + c.Assert(err, IsNil) + c.Assert(typeAsString(output), Equals, "*http.GitUploadPackService") + + e, err = common.NewEndpoint("https://github.com/src-d/go-git") + c.Assert(err, IsNil) + + output, err = NewGitUploadPackService(e) + c.Assert(err, IsNil) + c.Assert(typeAsString(output), Equals, "*http.GitUploadPackService") +} + +func (s *SuiteCommon) TestNewGitUploadPackServiceSSH(c *C) { + e, err := common.NewEndpoint("ssh://github.com/src-d/go-git") + c.Assert(err, IsNil) + + output, err := NewGitUploadPackService(e) + c.Assert(err, IsNil) + c.Assert(typeAsString(output), Equals, "*ssh.GitUploadPackService") +} + +func (s *SuiteCommon) TestNewGitUploadPackServiceUnknown(c *C) { + e, err := common.NewEndpoint("unknown://github.com/src-d/go-git") + c.Assert(err, IsNil) + + _, err = NewGitUploadPackService(e) + c.Assert(err, NotNil) +} + +func (s *SuiteCommon) TestInstallProtocol(c *C) { + InstallProtocol("newscheme", newDummyProtocolService) + c.Assert(Protocols["newscheme"], NotNil) +} + +type dummyProtocolService struct{} + +func newDummyProtocolService(common.Endpoint) common.GitUploadPackService { + return &dummyProtocolService{} +} + +func (s *dummyProtocolService) Connect() error { + return nil +} + +func (s *dummyProtocolService) SetAuth(auth common.AuthMethod) error { + return nil +} + +func (s *dummyProtocolService) Info() (*common.GitUploadPackInfo, error) { + return nil, nil +} + +func (s *dummyProtocolService) Fetch(r *common.GitUploadPackRequest) (io.ReadCloser, error) { + return nil, nil +} + +func (s *dummyProtocolService) Disconnect() error { + return nil +} + +func typeAsString(v interface{}) string { + return fmt.Sprintf("%T", v) +} |