From 064051f972e90dd55e6c941f04b58b4a36dfedf1 Mon Sep 17 00:00:00 2001 From: Máximo Cuadros Date: Wed, 26 Jul 2017 06:24:47 +0200 Subject: *: package context support in Repository, Remote and Submodule --- remote_test.go | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) (limited to 'remote_test.go') diff --git a/remote_test.go b/remote_test.go index 43276c2..ece052a 100644 --- a/remote_test.go +++ b/remote_test.go @@ -2,6 +2,7 @@ package git import ( "bytes" + "context" "io" "io/ioutil" "os" @@ -98,6 +99,23 @@ func (s *RemoteSuite) TestFetch(c *C) { }) } +func (s *RemoteSuite) TestFetchContext(c *C) { + r := newRemote(memory.NewStorage(), &config.RemoteConfig{ + URL: s.GetLocalRepositoryURL(fixtures.ByTag("tags").One()), + }) + + ctx, cancel := context.WithCancel(context.Background()) + cancel() + + err := r.FetchContext(ctx, &FetchOptions{ + RefSpecs: []config.RefSpec{ + config.RefSpec("+refs/heads/master:refs/remotes/origin/master"), + }, + }) + c.Assert(err, NotNil) + +} + func (s *RemoteSuite) TestFetchWithAllTags(c *C) { r := newRemote(memory.NewStorage(), &config.RemoteConfig{ URL: s.GetLocalRepositoryURL(fixtures.ByTag("tags").One()), @@ -340,6 +358,29 @@ func (s *RemoteSuite) TestPushToEmptyRepository(c *C) { } +func (s *RemoteSuite) TestPushContext(c *C) { + url := c.MkDir() + _, err := PlainInit(url, true) + 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) + + r := newRemote(sto, &config.RemoteConfig{ + Name: DefaultRemoteName, + URL: url, + }) + + ctx, cancel := context.WithCancel(context.Background()) + cancel() + + err = r.PushContext(ctx, &PushOptions{ + RefSpecs: []config.RefSpec{"refs/tags/*:refs/tags/*"}, + }) + c.Assert(err, NotNil) +} + func (s *RemoteSuite) TestPushTags(c *C) { url := c.MkDir() server, err := PlainInit(url, true) -- cgit