diff options
Diffstat (limited to 'internal/url/url_test.go')
-rwxr-xr-x | internal/url/url_test.go | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/internal/url/url_test.go b/internal/url/url_test.go new file mode 100755 index 0000000..d168db6 --- /dev/null +++ b/internal/url/url_test.go @@ -0,0 +1,60 @@ +package url + +import ( + "testing" + + . "gopkg.in/check.v1" +) + +func Test(t *testing.T) { TestingT(t) } + +type URLSuite struct{} + +var _ = Suite(&URLSuite{}) + +func (s *URLSuite) TestMatchesScpLike(c *C) { + examples := []string{ + "git@github.com:james/bond", + "git@github.com:007/bond", + "git@github.com:22:james/bond", + "git@github.com:22:007/bond", + } + + for _, url := range examples { + c.Check(MatchesScpLike(url), Equals, true) + } +} + +func (s *URLSuite) TestFindScpLikeComponents(c *C) { + url := "git@github.com:james/bond" + user, host, port, path := FindScpLikeComponents(url) + + c.Check(user, Equals, "git") + c.Check(host, Equals, "github.com") + c.Check(port, Equals, "") + c.Check(path, Equals, "james/bond") + + url = "git@github.com:007/bond" + user, host, port, path = FindScpLikeComponents(url) + + c.Check(user, Equals, "git") + c.Check(host, Equals, "github.com") + c.Check(port, Equals, "") + c.Check(path, Equals, "007/bond") + + url = "git@github.com:22:james/bond" + user, host, port, path = FindScpLikeComponents(url) + + c.Check(user, Equals, "git") + c.Check(host, Equals, "github.com") + c.Check(port, Equals, "22") + c.Check(path, Equals, "james/bond") + + url = "git@github.com:22:007/bond" + user, host, port, path = FindScpLikeComponents(url) + + c.Check(user, Equals, "git") + c.Check(host, Equals, "github.com") + c.Check(port, Equals, "22") + c.Check(path, Equals, "007/bond") +} |