|
| 1 | +package url |
| 2 | + |
| 3 | +import ( |
| 4 | + "testing" |
| 5 | + |
| 6 | + . "gopkg.in/check.v1" |
| 7 | +) |
| 8 | + |
| 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) { |
| 16 | + examples := []string{ |
| 17 | + |
| 18 | + |
| 19 | + "[email protected]:22:james/bond", |
| 20 | + |
| 21 | + } |
| 22 | + |
| 23 | + for _, url := range examples { |
| 24 | + c.Check(MatchesScpLike(url), Equals, true) |
| 25 | + } |
| 26 | +} |
| 27 | + |
| 28 | +func (s *URLSuite) TestFindScpLikeComponents(c *C) { |
| 29 | + url := "[email protected]:james/bond" |
| 30 | + user, host, port, path := FindScpLikeComponents(url) |
| 31 | + |
| 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") |
| 36 | + |
| 37 | + url = "[email protected]:007/bond" |
| 38 | + user, host, port, path = FindScpLikeComponents(url) |
| 39 | + |
| 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") |
| 44 | + |
| 45 | + url = "[email protected]:22:james/bond" |
| 46 | + user, host, port, path = FindScpLikeComponents(url) |
| 47 | + |
| 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") |
| 52 | + |
| 53 | + url = "[email protected]:22:007/bond" |
| 54 | + user, host, port, path = FindScpLikeComponents(url) |
| 55 | + |
| 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") |
| 60 | +} |
0 commit comments