aboutsummaryrefslogtreecommitdiffstats
path: root/common_test.go
diff options
context:
space:
mode:
authorMáximo Cuadros <mcuadros@gmail.com>2016-08-19 17:42:13 +0200
committerMáximo Cuadros <mcuadros@gmail.com>2016-08-19 17:42:13 +0200
commit1d56b98d9b02e20f7feea542c75746eab34fad63 (patch)
tree006e8c3ac5e40353032109a5259bb28c37751996 /common_test.go
parentb1d116c59f7656dc8d5ff7294ba8f8a82c51bfd1 (diff)
downloadgo-git-1d56b98d9b02e20f7feea542c75746eab34fad63.tar.gz
Remote.Fetch base on RefSpec, improvement of the responsabilities separation
Diffstat (limited to 'common_test.go')
-rw-r--r--common_test.go23
1 files changed, 20 insertions, 3 deletions
diff --git a/common_test.go b/common_test.go
index 3c373ec..386dc74 100644
--- a/common_test.go
+++ b/common_test.go
@@ -2,6 +2,7 @@ package git
import (
"bytes"
+ "errors"
"io"
"io/ioutil"
"os"
@@ -21,27 +22,34 @@ type BaseSuite struct{}
func (s *BaseSuite) SetUpTest(c *C) {
clients.InstallProtocol("mock", func(end common.Endpoint) common.GitUploadPackService {
- return &MockGitUploadPackService{conected: end}
+ return &MockGitUploadPackService{endpoint: end}
})
}
const RepositoryFixture = "mock://formats/packfile/fixtures/git-fixture.ref-delta"
type MockGitUploadPackService struct {
- conected common.Endpoint
- auth common.AuthMethod
+ connected bool
+ endpoint common.Endpoint
+ auth common.AuthMethod
}
func (p *MockGitUploadPackService) Connect() error {
+ p.connected = true
return nil
}
func (p *MockGitUploadPackService) ConnectWithAuth(auth common.AuthMethod) error {
+ p.connected = true
p.auth = auth
return nil
}
func (p *MockGitUploadPackService) Info() (*common.GitUploadPackInfo, error) {
+ if !p.connected {
+ return nil, errors.New("not connected")
+ }
+
h := core.NewHash("6ecf0ef2c2dffb796033e5a02219af86ec6584e5")
c := common.NewCapabilities()
@@ -62,9 +70,18 @@ func (p *MockGitUploadPackService) Info() (*common.GitUploadPackInfo, error) {
}
func (p *MockGitUploadPackService) Fetch(*common.GitUploadPackRequest) (io.ReadCloser, error) {
+ if !p.connected {
+ return nil, errors.New("not connected")
+ }
+
return os.Open("formats/packfile/fixtures/git-fixture.ref-delta")
}
+func (p *MockGitUploadPackService) Disconnect() error {
+ p.connected = false
+ return nil
+}
+
type packedFixture struct {
url string
packfile string