@@ -2,9 +2,17 @@ package url
2
2
3
3
import (
4
4
"testing"
5
+
6
+ . "gopkg.in/check.v1"
5
7
)
6
8
7
- func TestMatchesScpLike (t * testing.T ) {
9
+ func Test (t * testing.T ) { TestingT (t ) }
10
+
11
+ type URLSuite struct {}
12
+
13
+ var _ = Suite (& URLSuite {})
14
+
15
+ func (s * URLSuite ) TestMatchesScpLike (c * C ) {
8
16
examples := []string {
9
17
10
18
@@ -13,38 +21,40 @@ func TestMatchesScpLike(t *testing.T) {
13
21
}
14
22
15
23
for _ , url := range examples {
16
- if ! MatchesScpLike (url ) {
17
- t .Fatalf ("repo url %q did not match ScpLike" , url )
18
- }
24
+ c .Check (MatchesScpLike (url ), Equals , true )
19
25
}
20
26
}
21
27
22
- func TestFindScpLikeComponents (t * testing. T ) {
28
+ func ( s * URLSuite ) TestFindScpLikeComponents (c * C ) {
23
29
url := "[email protected] :james/bond"
24
30
user , host , port , path := FindScpLikeComponents (url )
25
31
26
- if user != "git" || host != "github.com" || port != "" || path != "james/bond" {
27
- t .Fatalf ("repo url %q did not match properly" , user )
28
- }
32
+ c .Check (user , Equals , "git" )
33
+ c .Check (host , Equals , "github.com" )
34
+ c .Check (port , Equals , "" )
35
+ c .Check (path , Equals , "james/bond" )
29
36
30
37
url = "[email protected] :007/bond"
31
38
user , host , port , path = FindScpLikeComponents (url )
32
39
33
- if user != "git" || host != "github.com" || port != "" || path != "007/bond" {
34
- t .Fatalf ("repo url %q did not match properly" , user )
35
- }
40
+ c .Check (user , Equals , "git" )
41
+ c .Check (host , Equals , "github.com" )
42
+ c .Check (port , Equals , "" )
43
+ c .Check (path , Equals , "007/bond" )
36
44
37
45
url = "[email protected] :22:james/bond"
38
46
user , host , port , path = FindScpLikeComponents (url )
39
47
40
- if user != "git" || host != "github.com" || port != "22" || path != "james/bond" {
41
- t .Fatalf ("repo url %q did not match properly" , user )
42
- }
48
+ c .Check (user , Equals , "git" )
49
+ c .Check (host , Equals , "github.com" )
50
+ c .Check (port , Equals , "22" )
51
+ c .Check (path , Equals , "james/bond" )
43
52
44
53
url = "[email protected] :22:007/bond"
45
54
user , host , port , path = FindScpLikeComponents (url )
46
55
47
- if user != "git" || host != "github.com" || port != "22" || path != "007/bond" {
48
- t .Fatalf ("repo url %q did not match properly" , user )
49
- }
56
+ c .Check (user , Equals , "git" )
57
+ c .Check (host , Equals , "github.com" )
58
+ c .Check (port , Equals , "22" )
59
+ c .Check (path , Equals , "007/bond" )
50
60
}
0 commit comments