1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
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)
}
|