aboutsummaryrefslogtreecommitdiffstats
path: root/clients/common_test.go
diff options
context:
space:
mode:
authorAlberto Cortés <alberto@sourced.tech>2015-12-16 19:41:29 +0100
committerAlberto Cortés <alberto@sourced.tech>2015-12-16 19:41:29 +0100
commitbf98b6096fd1e813ebadbb1f71d4b2d4e48bdb4b (patch)
tree662e91b988a5bf79fe9c6d1a02a2df91d4596d27 /clients/common_test.go
parent990573b9bf06d12fdafbe09664e47736a48746d8 (diff)
downloadgo-git-bf98b6096fd1e813ebadbb1f71d4b2d4e48bdb4b.tar.gz
Add client selection based on repo URL scheme
Diffstat (limited to 'clients/common_test.go')
-rw-r--r--clients/common_test.go38
1 files changed, 38 insertions, 0 deletions
diff --git a/clients/common_test.go b/clients/common_test.go
new file mode 100644
index 0000000..f8bcbd3
--- /dev/null
+++ b/clients/common_test.go
@@ -0,0 +1,38 @@
+package clients
+
+import (
+ "fmt"
+ "testing"
+
+ . "gopkg.in/check.v1"
+)
+
+func Test(t *testing.T) { TestingT(t) }
+
+type SuiteCommon struct{}
+
+var _ = Suite(&SuiteCommon{})
+
+func (s *SuiteCommon) TestNewGitUploadPackService(c *C) {
+ var tests = [...]struct {
+ input string
+ err bool
+ expected string
+ }{
+ {"ht/ml://example.com", true, "<nil>"},
+ {"", true, "<nil>"},
+ {"-", true, "<nil>"},
+ {"!@", true, "<nil>"},
+ {"badscheme://github.com/src-d/go-git", true, "<nil>"},
+ {"http://github.com/src-d/go-git", false, "*http.GitUploadPackService"},
+ {"https://github.com/src-d/go-git", false, "*http.GitUploadPackService"},
+ {"ssh://github.com/src-d/go-git", false, "*ssh.GitUploadPackService"},
+ {"file://github.com/src-d/go-git", false, "*file.GitUploadPackService"},
+ }
+
+ for i, t := range tests {
+ output, err := NewGitUploadPackService(t.input)
+ c.Assert(err != nil, Equals, t.err, Commentf("%d) %q: wrong error value", i, t.input))
+ c.Assert(fmt.Sprintf("%T", output), Equals, t.expected, Commentf("%d) %q: wrong type", i, t.input))
+ }
+}