aboutsummaryrefslogtreecommitdiffstats
path: root/common_test.go
diff options
context:
space:
mode:
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