aboutsummaryrefslogtreecommitdiffstats
path: root/remote_test.go
diff options
context:
space:
mode:
authorMáximo Cuadros <mcuadros@gmail.com>2018-10-15 12:21:23 +0200
committerMáximo Cuadros <mcuadros@gmail.com>2018-10-15 12:21:23 +0200
commit7a77bde9448c15251cdcca14db20b7bf5c798692 (patch)
tree4fa875f1fa57b01dcdfdb17d1b3ba2d0519bd493 /remote_test.go
parent0b7d3fe0a47bd7da9c42ba34b9098441120bda02 (diff)
parent345ffd95a2cd1413d7f48280e21a035febbe4e10 (diff)
downloadgo-git-7a77bde9448c15251cdcca14db20b7bf5c798692.tar.gz
Merge branch 'master' of github.com:src-d/go-git into annotated
Diffstat (limited to 'remote_test.go')
-rw-r--r--remote_test.go49
1 files changed, 27 insertions, 22 deletions
diff --git a/remote_test.go b/remote_test.go
index 82ec1fc..175faed 100644
--- a/remote_test.go
+++ b/remote_test.go
@@ -9,6 +9,7 @@ import (
"gopkg.in/src-d/go-git.v4/config"
"gopkg.in/src-d/go-git.v4/plumbing"
+ "gopkg.in/src-d/go-git.v4/plumbing/cache"
"gopkg.in/src-d/go-git.v4/plumbing/protocol/packp"
"gopkg.in/src-d/go-git.v4/plumbing/storer"
"gopkg.in/src-d/go-git.v4/storage"
@@ -100,6 +101,20 @@ func (s *RemoteSuite) TestFetch(c *C) {
})
}
+func (s *RemoteSuite) TestFetchNonExistantReference(c *C) {
+ r := newRemote(memory.NewStorage(), &config.RemoteConfig{
+ URLs: []string{s.GetLocalRepositoryURL(fixtures.ByTag("tags").One())},
+ })
+
+ err := r.Fetch(&FetchOptions{
+ RefSpecs: []config.RefSpec{
+ config.RefSpec("+refs/heads/foo:refs/remotes/origin/foo"),
+ },
+ })
+
+ c.Assert(err, ErrorMatches, "couldn't find remote ref.*")
+}
+
func (s *RemoteSuite) TestFetchContext(c *C) {
r := newRemote(memory.NewStorage(), &config.RemoteConfig{
URLs: []string{s.GetLocalRepositoryURL(fixtures.ByTag("tags").One())},
@@ -224,7 +239,7 @@ func (s *RemoteSuite) TestFetchWithPackfileWriter(c *C) {
defer os.RemoveAll(dir) // clean up
- fss, err := filesystem.NewStorage(osfs.New(dir))
+ fss := filesystem.NewStorage(osfs.New(dir), cache.NewObjectLRUDefault())
c.Assert(err, IsNil)
mock := &mockPackfileWriter{Storer: fss}
@@ -361,8 +376,7 @@ func (s *RemoteSuite) TestFetchFastForwardFS(c *C) {
defer os.RemoveAll(dir) // clean up
- fss, err := filesystem.NewStorage(osfs.New(dir))
- c.Assert(err, IsNil)
+ fss := filesystem.NewStorage(osfs.New(dir), cache.NewObjectLRUDefault())
// This exercises `storage.filesystem.Storage.CheckAndSetReference()`.
s.testFetchFastForward(c, fss)
@@ -386,8 +400,7 @@ func (s *RemoteSuite) TestPushToEmptyRepository(c *C) {
c.Assert(err, IsNil)
srcFs := fixtures.Basic().One().DotGit()
- sto, err := filesystem.NewStorage(srcFs)
- c.Assert(err, IsNil)
+ sto := filesystem.NewStorage(srcFs, cache.NewObjectLRUDefault())
r := newRemote(sto, &config.RemoteConfig{
Name: DefaultRemoteName,
@@ -424,8 +437,7 @@ func (s *RemoteSuite) TestPushContext(c *C) {
c.Assert(err, IsNil)
fs := fixtures.ByURL("https://github.com/git-fixtures/tags.git").One().DotGit()
- sto, err := filesystem.NewStorage(fs)
- c.Assert(err, IsNil)
+ sto := filesystem.NewStorage(fs, cache.NewObjectLRUDefault())
r := newRemote(sto, &config.RemoteConfig{
Name: DefaultRemoteName,
@@ -447,8 +459,7 @@ func (s *RemoteSuite) TestPushTags(c *C) {
c.Assert(err, IsNil)
fs := fixtures.ByURL("https://github.com/git-fixtures/tags.git").One().DotGit()
- sto, err := filesystem.NewStorage(fs)
- c.Assert(err, IsNil)
+ sto := filesystem.NewStorage(fs, cache.NewObjectLRUDefault())
r := newRemote(sto, &config.RemoteConfig{
Name: DefaultRemoteName,
@@ -471,15 +482,14 @@ func (s *RemoteSuite) TestPushTags(c *C) {
func (s *RemoteSuite) TestPushNoErrAlreadyUpToDate(c *C) {
fs := fixtures.Basic().One().DotGit()
- sto, err := filesystem.NewStorage(fs)
- c.Assert(err, IsNil)
+ sto := filesystem.NewStorage(fs, cache.NewObjectLRUDefault())
r := newRemote(sto, &config.RemoteConfig{
Name: DefaultRemoteName,
URLs: []string{fs.Root()},
})
- err = r.Push(&PushOptions{
+ err := r.Push(&PushOptions{
RefSpecs: []config.RefSpec{"refs/heads/*:refs/heads/*"},
})
c.Assert(err, Equals, NoErrAlreadyUpToDate)
@@ -487,8 +497,7 @@ func (s *RemoteSuite) TestPushNoErrAlreadyUpToDate(c *C) {
func (s *RemoteSuite) TestPushDeleteReference(c *C) {
fs := fixtures.Basic().One().DotGit()
- sto, err := filesystem.NewStorage(fs)
- c.Assert(err, IsNil)
+ sto := filesystem.NewStorage(fs, cache.NewObjectLRUDefault())
r, err := PlainClone(c.MkDir(), true, &CloneOptions{
URL: fs.Root(),
@@ -512,8 +521,7 @@ func (s *RemoteSuite) TestPushDeleteReference(c *C) {
func (s *RemoteSuite) TestPushRejectNonFastForward(c *C) {
fs := fixtures.Basic().One().DotGit()
- server, err := filesystem.NewStorage(fs)
- c.Assert(err, IsNil)
+ server := filesystem.NewStorage(fs, cache.NewObjectLRUDefault())
r, err := PlainClone(c.MkDir(), true, &CloneOptions{
URL: fs.Root(),
@@ -540,12 +548,10 @@ func (s *RemoteSuite) TestPushRejectNonFastForward(c *C) {
func (s *RemoteSuite) TestPushForce(c *C) {
f := fixtures.Basic().One()
- sto, err := filesystem.NewStorage(f.DotGit())
- c.Assert(err, IsNil)
+ sto := filesystem.NewStorage(f.DotGit(), cache.NewObjectLRUDefault())
dstFs := f.DotGit()
- dstSto, err := filesystem.NewStorage(dstFs)
- c.Assert(err, IsNil)
+ dstSto := filesystem.NewStorage(dstFs, cache.NewObjectLRUDefault())
url := dstFs.Root()
r := newRemote(sto, &config.RemoteConfig{
@@ -689,8 +695,7 @@ func (s *RemoteSuite) TestPushWrongRemoteName(c *C) {
func (s *RemoteSuite) TestGetHaves(c *C) {
f := fixtures.Basic().One()
- sto, err := filesystem.NewStorage(f.DotGit())
- c.Assert(err, IsNil)
+ sto := filesystem.NewStorage(f.DotGit(), cache.NewObjectLRUDefault())
var localRefs = []*plumbing.Reference{
plumbing.NewReferenceFromStrings(