diff options
author | Máximo Cuadros <mcuadros@gmail.com> | 2016-09-22 23:41:48 +0200 |
---|---|---|
committer | Máximo Cuadros <mcuadros@gmail.com> | 2016-09-22 23:41:48 +0200 |
commit | 5913aee5004ff5b32c7926dda3af1f946d203f33 (patch) | |
tree | c9b3ce9e4439faf0313749690a3a0e496e32447d /remote_test.go | |
parent | 001bb130fe6186421f3ddcc556854410edd8d95e (diff) | |
download | go-git-5913aee5004ff5b32c7926dda3af1f946d203f33.tar.gz |
test coverage improved, Remote.Refs and Repository.Refs returns error, TreeWalker -> TreeIter
Diffstat (limited to 'remote_test.go')
-rw-r--r-- | remote_test.go | 54 |
1 files changed, 49 insertions, 5 deletions
diff --git a/remote_test.go b/remote_test.go index e19f7b8..12e4625 100644 --- a/remote_test.go +++ b/remote_test.go @@ -1,9 +1,14 @@ package git import ( + "io/ioutil" + "os" + "gopkg.in/src-d/go-git.v4/config" "gopkg.in/src-d/go-git.v4/core" + "gopkg.in/src-d/go-git.v4/storage/filesystem" "gopkg.in/src-d/go-git.v4/storage/memory" + "gopkg.in/src-d/go-git.v4/utils/fs" . "gopkg.in/check.v1" ) @@ -14,10 +19,6 @@ type RemoteSuite struct { var _ = Suite(&RemoteSuite{}) -func (s *RemoteSuite) SetUpSuite(c *C) { - s.installMockProtocol(c) -} - func (s *RemoteSuite) TestConnect(c *C) { r := newRemote(nil, &config.RemoteConfig{Name: "foo", URL: RepositoryFixture}) @@ -80,6 +81,38 @@ func (s *RemoteSuite) TestFetch(c *C) { c.Assert(sto.ObjectStorage().(*memory.ObjectStorage).Objects, HasLen, 31) } +func (s *RemoteSuite) TestFetchObjectStorageWriter(c *C) { + dir, err := ioutil.TempDir("", "fetch") + c.Assert(err, IsNil) + + defer os.RemoveAll(dir) // clean up + + var sto Storage + sto, err = filesystem.NewStorage(fs.NewOS(dir)) + c.Assert(err, IsNil) + + r := newRemote(sto, &config.RemoteConfig{Name: "foo", URL: RepositoryFixture}) + r.upSrv = &MockGitUploadPackService{} + + c.Assert(r.Connect(), IsNil) + + err = r.Fetch(&FetchOptions{ + RefSpecs: []config.RefSpec{config.DefaultRefSpec}, + }) + + c.Assert(err, IsNil) + + var count int + iter, err := sto.ObjectStorage().Iter(core.AnyObject) + c.Assert(err, IsNil) + + iter.ForEach(func(core.Object) error { + count++ + return nil + }) + c.Assert(count, Equals, 31) +} + func (s *RemoteSuite) TestFetchNoErrAlreadyUpToDate(c *C) { sto := memory.NewStorage() r := newRemote(sto, &config.RemoteConfig{Name: "foo", URL: RepositoryFixture}) @@ -128,5 +161,16 @@ func (s *RemoteSuite) TestRefs(c *C) { err := r.Connect() c.Assert(err, IsNil) - c.Assert(r.Refs(), NotNil) + + iter, err := r.Refs() + c.Assert(err, IsNil) + c.Assert(iter, NotNil) +} + +func (s *RemoteSuite) TestString(c *C) { + r := newRemote(nil, &config.RemoteConfig{Name: "foo", URL: RepositoryFixture}) + c.Assert(r.String(), Equals, ""+ + "foo\thttps://github.com/git-fixtures/basic.git (fetch)\n"+ + "foo\thttps://github.com/git-fixtures/basic.git (push)", + ) } |