@@ -14,22 +14,118 @@ type SuiteCommon struct{}
14
14
15
15
var _ = Suite (& SuiteCommon {})
16
16
17
- func (s * SuiteCommon ) TestNewEndpoint (c * C ) {
17
+ func (s * SuiteCommon ) TestNewEndpointHTTP (c * C ) {
18
+ e ,
err := NewEndpoint (
"http://git:[email protected] /user/repository.git?foo#bar" )
19
+ c .Assert (err , IsNil )
20
+ c .Assert (e .Protocol (), Equals , "http" )
21
+ c .Assert (e .User (), Equals , "git" )
22
+ c .Assert (e .Password (), Equals , "pass" )
23
+ c .Assert (e .Host (), Equals , "github.com" )
24
+ c .Assert (e .Port (), Equals , 0 )
25
+ c .Assert (e .Path (), Equals , "/user/repository.git?foo#bar" )
26
+ c .
Assert (
e .
String (),
Equals ,
"http://git:[email protected] /user/repository.git?foo#bar" )
27
+ }
28
+
29
+ func (s * SuiteCommon ) TestNewEndpointSSH (c * C ) {
18
30
e ,
err := NewEndpoint (
"ssh://[email protected] /user/repository.git" )
19
31
c .Assert (err , IsNil )
32
+ c .Assert (e .Protocol (), Equals , "ssh" )
33
+ c .Assert (e .User (), Equals , "git" )
34
+ c .Assert (e .Password (), Equals , "" )
35
+ c .Assert (e .Host (), Equals , "github.com" )
36
+ c .Assert (e .Port (), Equals , 0 )
37
+ c .Assert (e .Path (), Equals , "/user/repository.git" )
20
38
c .
Assert (
e .
String (),
Equals ,
"ssh://[email protected] /user/repository.git" )
21
39
}
22
40
41
+ func (s * SuiteCommon ) TestNewEndpointSSHNoUser (c * C ) {
42
+ e , err := NewEndpoint ("ssh://github.com/user/repository.git" )
43
+ c .Assert (err , IsNil )
44
+ c .Assert (e .Protocol (), Equals , "ssh" )
45
+ c .Assert (e .User (), Equals , "" )
46
+ c .Assert (e .Password (), Equals , "" )
47
+ c .Assert (e .Host (), Equals , "github.com" )
48
+ c .Assert (e .Port (), Equals , 0 )
49
+ c .Assert (e .Path (), Equals , "/user/repository.git" )
50
+ c .Assert (e .String (), Equals , "ssh://github.com/user/repository.git" )
51
+ }
52
+
53
+ func (s * SuiteCommon ) TestNewEndpointSSHWithPort (c * C ) {
54
+ e ,
err := NewEndpoint (
"ssh://[email protected] :777/user/repository.git" )
55
+ c .Assert (err , IsNil )
56
+ c .Assert (e .Protocol (), Equals , "ssh" )
57
+ c .Assert (e .User (), Equals , "git" )
58
+ c .Assert (e .Password (), Equals , "" )
59
+ c .Assert (e .Host (), Equals , "github.com" )
60
+ c .Assert (e .Port (), Equals , 777 )
61
+ c .Assert (e .Path (), Equals , "/user/repository.git" )
62
+ c .
Assert (
e .
String (),
Equals ,
"ssh://[email protected] :777/user/repository.git" )
63
+ }
64
+
23
65
func (s * SuiteCommon ) TestNewEndpointSCPLike (c * C ) {
24
66
e ,
err := NewEndpoint (
"[email protected] :user/repository.git" )
25
67
c .Assert (err , IsNil )
26
- c .
Assert (
e .
String (),
Equals ,
"ssh://[email protected] /user/repository.git" )
68
+ c .Assert (e .Protocol (), Equals , "ssh" )
69
+ c .Assert (e .User (), Equals , "git" )
70
+ c .Assert (e .Password (), Equals , "" )
71
+ c .Assert (e .Host (), Equals , "github.com" )
72
+ c .Assert (e .Port (), Equals , 22 )
73
+ c .Assert (e .Path (), Equals , "user/repository.git" )
74
+ c .
Assert (
e .
String (),
Equals ,
"[email protected] :user/repository.git" )
75
+ }
76
+
77
+ func (s * SuiteCommon ) TestNewEndpointFileAbs (c * C ) {
78
+ e , err := NewEndpoint ("/foo.git" )
79
+ c .Assert (err , IsNil )
80
+ c .Assert (e .Protocol (), Equals , "file" )
81
+ c .Assert (e .User (), Equals , "" )
82
+ c .Assert (e .Password (), Equals , "" )
83
+ c .Assert (e .Host (), Equals , "" )
84
+ c .Assert (e .Port (), Equals , 0 )
85
+ c .Assert (e .Path (), Equals , "/foo.git" )
86
+ c .Assert (e .String (), Equals , "/foo.git" )
87
+ }
88
+
89
+ func (s * SuiteCommon ) TestNewEndpointFileRel (c * C ) {
90
+ e , err := NewEndpoint ("foo.git" )
91
+ c .Assert (err , IsNil )
92
+ c .Assert (e .Protocol (), Equals , "file" )
93
+ c .Assert (e .User (), Equals , "" )
94
+ c .Assert (e .Password (), Equals , "" )
95
+ c .Assert (e .Host (), Equals , "" )
96
+ c .Assert (e .Port (), Equals , 0 )
97
+ c .Assert (e .Path (), Equals , "foo.git" )
98
+ c .Assert (e .String (), Equals , "foo.git" )
99
+ }
100
+
101
+ func (s * SuiteCommon ) TestNewEndpointFileWindows (c * C ) {
102
+ e , err := NewEndpoint ("C:\\ foo.git" )
103
+ c .Assert (err , IsNil )
104
+ c .Assert (e .Protocol (), Equals , "file" )
105
+ c .Assert (e .User (), Equals , "" )
106
+ c .Assert (e .Password (), Equals , "" )
107
+ c .Assert (e .Host (), Equals , "" )
108
+ c .Assert (e .Port (), Equals , 0 )
109
+ c .Assert (e .Path (), Equals , "C:\\ foo.git" )
110
+ c .Assert (e .String (), Equals , "C:\\ foo.git" )
111
+ }
112
+
113
+ func (s * SuiteCommon ) TestNewEndpointFileURL (c * C ) {
114
+ e , err := NewEndpoint ("file:///foo.git" )
115
+ c .Assert (err , IsNil )
116
+ c .Assert (e .Protocol (), Equals , "file" )
117
+ c .Assert (e .User (), Equals , "" )
118
+ c .Assert (e .Password (), Equals , "" )
119
+ c .Assert (e .Host (), Equals , "" )
120
+ c .Assert (e .Port (), Equals , 0 )
121
+ c .Assert (e .Path (), Equals , "/foo.git" )
122
+ c .Assert (e .String (), Equals , "file:///foo.git" )
27
123
}
28
124
29
- func (s * SuiteCommon ) TestNewEndpointWrongForgat (c * C ) {
30
- e , err := NewEndpoint ("foo " )
31
- c .Assert (err , Not ( IsNil ) )
32
- c .Assert (e . Host , Equals , "" )
125
+ func (s * SuiteCommon ) TestNewEndpointInvalidURL (c * C ) {
126
+ e , err := NewEndpoint ("http:// \\ " )
127
+ c .Assert (err , NotNil )
128
+ c .Assert (e , IsNil )
33
129
}
34
130
35
131
func (s * SuiteCommon ) TestFilterUnsupportedCapabilities (c * C ) {
0 commit comments