aboutsummaryrefslogtreecommitdiffstats
path: root/remote_test.go
diff options
context:
space:
mode:
authorMáximo Cuadros <mcuadros@gmail.com>2016-11-07 20:29:58 +0100
committerGitHub <noreply@github.com>2016-11-07 20:29:58 +0100
commit0ff9ef2b44c53e557c78bde0fd9c29847e5f0e23 (patch)
treeb9c7485fe99e6e89fa736ceb0223aeb2ecddb77c /remote_test.go
parentf6ed7424cbf33c7013332d7e95b4262a4bc4a523 (diff)
downloadgo-git-0ff9ef2b44c53e557c78bde0fd9c29847e5f0e23.tar.gz
global storage interface refactor (#112)
* core: ObjectStorage, ReferenceStorage renamed to ObjectStorer and ReferenceStorer * rebase * general, changes request by @alcortes * general, changes request by @alcortes
Diffstat (limited to 'remote_test.go')
-rw-r--r--remote_test.go28
1 files changed, 21 insertions, 7 deletions
diff --git a/remote_test.go b/remote_test.go
index 37539af..04167cd 100644
--- a/remote_test.go
+++ b/remote_test.go
@@ -1,6 +1,7 @@
package git
import (
+ "io"
"io/ioutil"
"os"
@@ -80,7 +81,7 @@ func (s *RemoteSuite) TestFetch(c *C) {
})
c.Assert(err, IsNil)
- c.Assert(sto.ObjectStorage().(*memory.ObjectStorage).Objects, HasLen, 31)
+ c.Assert(sto.Objects, HasLen, 31)
expectedRefs := []*core.Reference{
core.NewReferenceFromStrings("refs/remotes/origin/master", "6ecf0ef2c2dffb796033e5a02219af86ec6584e5"),
@@ -89,22 +90,33 @@ func (s *RemoteSuite) TestFetch(c *C) {
}
for _, exp := range expectedRefs {
- r, _ := sto.ReferenceStorage().Get(exp.Name())
+ r, _ := sto.Reference(exp.Name())
c.Assert(exp.String(), Equals, r.String())
}
}
-func (s *RemoteSuite) TestFetchObjectStorageWriter(c *C) {
+type mockPackfileWriter struct {
+ Storer
+ PackfileWriterCalled bool
+}
+
+func (m *mockPackfileWriter) PackfileWriter() (io.WriteCloser, error) {
+ m.PackfileWriterCalled = true
+ return m.Storer.(core.PackfileWriter).PackfileWriter()
+}
+
+func (s *RemoteSuite) TestFetchWithPackfileWriter(c *C) {
dir, err := ioutil.TempDir("", "fetch")
c.Assert(err, IsNil)
defer os.RemoveAll(dir) // clean up
- var sto Storage
- sto, err = filesystem.NewStorage(osfs.New(dir))
+ fss, err := filesystem.NewStorage(osfs.New(dir))
c.Assert(err, IsNil)
- r := newRemote(sto, &config.RemoteConfig{Name: "foo", URL: RepositoryFixture})
+ mock := &mockPackfileWriter{Storer: fss}
+
+ r := newRemote(mock, &config.RemoteConfig{Name: "foo", URL: RepositoryFixture})
r.upSrv = &MockGitUploadPackService{}
c.Assert(r.Connect(), IsNil)
@@ -116,14 +128,16 @@ func (s *RemoteSuite) TestFetchObjectStorageWriter(c *C) {
c.Assert(err, IsNil)
var count int
- iter, err := sto.ObjectStorage().Iter(core.AnyObject)
+ iter, err := mock.IterObjects(core.AnyObject)
c.Assert(err, IsNil)
iter.ForEach(func(core.Object) error {
count++
return nil
})
+
c.Assert(count, Equals, 31)
+ c.Assert(mock.PackfileWriterCalled, Equals, true)
}
func (s *RemoteSuite) TestFetchNoErrAlreadyUpToDate(c *C) {