Skip to content

Commit 4c43218

Browse files
author
Chief
committed
Use gocheck for test.
Signed-off-by: Chief <[email protected]>
1 parent 80d88d9 commit 4c43218

File tree

1 file changed

+27
-17
lines changed

1 file changed

+27
-17
lines changed

internal/url/url_test.go

100644100755
+27-17
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,17 @@ package url
22

33
import (
44
"testing"
5+
6+
. "gopkg.in/check.v1"
57
)
68

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) {
816
examples := []string{
917
"[email protected]:james/bond",
1018
"[email protected]:007/bond",
@@ -13,38 +21,40 @@ func TestMatchesScpLike(t *testing.T) {
1321
}
1422

1523
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)
1925
}
2026
}
2127

22-
func TestFindScpLikeComponents(t *testing.T) {
28+
func (s *URLSuite) TestFindScpLikeComponents(c *C) {
2329
url := "[email protected]:james/bond"
2430
user, host, port, path := FindScpLikeComponents(url)
2531

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")
2936

3037
url = "[email protected]:007/bond"
3138
user, host, port, path = FindScpLikeComponents(url)
3239

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")
3644

3745
url = "[email protected]:22:james/bond"
3846
user, host, port, path = FindScpLikeComponents(url)
3947

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")
4352

4453
url = "[email protected]:22:007/bond"
4554
user, host, port, path = FindScpLikeComponents(url)
4655

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")
5060
}

0 commit comments

Comments
 (0)