aboutsummaryrefslogtreecommitdiffstats
path: root/remote_test.go
diff options
context:
space:
mode:
authorMáximo Cuadros <mcuadros@gmail.com>2017-07-26 14:41:59 +0200
committerGitHub <noreply@github.com>2017-07-26 14:41:59 +0200
commite19163e22eb19b352dd022f6edc9d81e1cd7a7ed (patch)
treeca08a52fdb31bd90637cec71351578436f254b4b /remote_test.go
parentd7b898ea3be0342f064ad63f93aaffdb6518a5b3 (diff)
parent064051f972e90dd55e6c941f04b58b4a36dfedf1 (diff)
downloadgo-git-e19163e22eb19b352dd022f6edc9d81e1cd7a7ed.tar.gz
Merge pull request #509 from mcuadros/ctx-main
*: package context support in Repository, Remote and Submodule
Diffstat (limited to 'remote_test.go')
-rw-r--r--remote_test.go41
1 files changed, 41 insertions, 0 deletions
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)