diff options
Diffstat (limited to 'clients')
-rw-r--r-- | clients/common.go | 4 | ||||
-rw-r--r-- | clients/common/common.go | 6 | ||||
-rw-r--r-- | clients/common_test.go | 35 | ||||
-rw-r--r-- | clients/ssh/git_upload_pack_test.go | 2 |
4 files changed, 32 insertions, 15 deletions
diff --git a/clients/common.go b/clients/common.go index 55b3b4b..b6da656 100644 --- a/clients/common.go +++ b/clients/common.go @@ -55,10 +55,10 @@ func NewGitUploadPackService(repoURL string) (common.GitUploadPackService, error if err != nil { return nil, fmt.Errorf("invalid url %q", repoURL) } - service, ok := KnownProtocols[u.Scheme] + s, ok := KnownProtocols[u.Scheme] if !ok { return nil, fmt.Errorf("unsupported scheme %q", u.Scheme) } - return service, nil + return s, nil } diff --git a/clients/common/common.go b/clients/common/common.go index 5aa6269..7280450 100644 --- a/clients/common/common.go +++ b/clients/common/common.go @@ -236,11 +236,7 @@ func (r *GitUploadPackInfo) decodeHeaderLine(line string) { } func (r *GitUploadPackInfo) isValidLine(line string) bool { - if line[0] == '#' { - return false - } - - return true + return line[0] != '#' } func (r *GitUploadPackInfo) readLine(line string) { diff --git a/clients/common_test.go b/clients/common_test.go index 88f66ab..c571f04 100644 --- a/clients/common_test.go +++ b/clients/common_test.go @@ -3,23 +3,41 @@ package clients import ( "fmt" "io" + "os" "testing" - . "gopkg.in/check.v1" "gopkg.in/src-d/go-git.v3/clients/common" + + "github.com/alcortesm/tgz" + . "gopkg.in/check.v1" ) func Test(t *testing.T) { TestingT(t) } -type SuiteCommon struct{} +type SuiteCommon struct { + dirFixturePath string +} var _ = Suite(&SuiteCommon{}) +const fixtureTGZ = "../storage/seekable/internal/gitdir/fixtures/spinnaker-gc.tgz" + +func (s *SuiteCommon) SetUpSuite(c *C) { + var err error + s.dirFixturePath, err = tgz.Extract(fixtureTGZ) + c.Assert(err, IsNil) +} + +func (s *SuiteCommon) TearDownSuite(c *C) { + err := os.RemoveAll(s.dirFixturePath) + c.Assert(err, IsNil) +} + func (s *SuiteCommon) TestNewGitUploadPackService(c *C) { var tests = [...]struct { - input string - err bool - expected string + input string + err bool + exp string }{ {"://example.com", true, "<nil>"}, {"badscheme://github.com/src-d/go-git", true, "<nil>"}, @@ -30,8 +48,10 @@ func (s *SuiteCommon) TestNewGitUploadPackService(c *C) { 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(typeAsString(output), Equals, t.expected, Commentf("%d) %q: wrong type", i, t.input)) + c.Assert(err != nil, Equals, t.err, + Commentf("%d) %q: wrong error value (was: %s)", i, t.input, err)) + c.Assert(typeAsString(output), Equals, t.exp, + Commentf("%d) %q: wrong type", i, t.input)) } } @@ -70,7 +90,6 @@ func (s *SuiteCommon) TestInstallProtocol(c *C) { for i, t := range tests { if t.panic { - fmt.Println(t.service == nil) c.Assert(func() { InstallProtocol(t.scheme, t.service) }, PanicMatches, `nil service`) continue } diff --git a/clients/ssh/git_upload_pack_test.go b/clients/ssh/git_upload_pack_test.go index 4b50c4c..07aa816 100644 --- a/clients/ssh/git_upload_pack_test.go +++ b/clients/ssh/git_upload_pack_test.go @@ -1,3 +1,5 @@ +// +build ssh + package ssh import ( |