aboutsummaryrefslogtreecommitdiffstats
path: root/remote_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'remote_test.go')
-rw-r--r--remote_test.go57
1 files changed, 28 insertions, 29 deletions
diff --git a/remote_test.go b/remote_test.go
index ece052a..e2fd8ae 100644
--- a/remote_test.go
+++ b/remote_test.go
@@ -26,25 +26,25 @@ type RemoteSuite struct {
var _ = Suite(&RemoteSuite{})
func (s *RemoteSuite) TestFetchInvalidEndpoint(c *C) {
- r := newRemote(nil, &config.RemoteConfig{Name: "foo", URL: "http://\\"})
+ r := newRemote(nil, &config.RemoteConfig{Name: "foo", URLs: []string{"http://\\"}})
err := r.Fetch(&FetchOptions{RemoteName: "foo"})
c.Assert(err, ErrorMatches, ".*invalid character.*")
}
func (s *RemoteSuite) TestFetchNonExistentEndpoint(c *C) {
- r := newRemote(nil, &config.RemoteConfig{Name: "foo", URL: "ssh://non-existent/foo.git"})
+ r := newRemote(nil, &config.RemoteConfig{Name: "foo", URLs: []string{"ssh://non-existent/foo.git"}})
err := r.Fetch(&FetchOptions{})
c.Assert(err, NotNil)
}
func (s *RemoteSuite) TestFetchInvalidSchemaEndpoint(c *C) {
- r := newRemote(nil, &config.RemoteConfig{Name: "foo", URL: "qux://foo"})
+ r := newRemote(nil, &config.RemoteConfig{Name: "foo", URLs: []string{"qux://foo"}})
err := r.Fetch(&FetchOptions{})
c.Assert(err, ErrorMatches, ".*unsupported scheme.*")
}
func (s *RemoteSuite) TestFetchInvalidFetchOptions(c *C) {
- r := newRemote(nil, &config.RemoteConfig{Name: "foo", URL: "qux://foo"})
+ r := newRemote(nil, &config.RemoteConfig{Name: "foo", URLs: []string{"qux://foo"}})
invalid := config.RefSpec("^*$ñ")
err := r.Fetch(&FetchOptions{RefSpecs: []config.RefSpec{invalid}})
c.Assert(err, Equals, config.ErrRefSpecMalformedSeparator)
@@ -52,7 +52,7 @@ func (s *RemoteSuite) TestFetchInvalidFetchOptions(c *C) {
func (s *RemoteSuite) TestFetchWildcard(c *C) {
r := newRemote(memory.NewStorage(), &config.RemoteConfig{
- URL: s.GetBasicLocalRepositoryURL(),
+ URLs: []string{s.GetBasicLocalRepositoryURL()},
})
s.testFetch(c, r, &FetchOptions{
@@ -68,7 +68,7 @@ func (s *RemoteSuite) TestFetchWildcard(c *C) {
func (s *RemoteSuite) TestFetchWildcardTags(c *C) {
r := newRemote(memory.NewStorage(), &config.RemoteConfig{
- URL: s.GetLocalRepositoryURL(fixtures.ByTag("tags").One()),
+ URLs: []string{s.GetLocalRepositoryURL(fixtures.ByTag("tags").One())},
})
s.testFetch(c, r, &FetchOptions{
@@ -87,7 +87,7 @@ func (s *RemoteSuite) TestFetchWildcardTags(c *C) {
func (s *RemoteSuite) TestFetch(c *C) {
r := newRemote(memory.NewStorage(), &config.RemoteConfig{
- URL: s.GetLocalRepositoryURL(fixtures.ByTag("tags").One()),
+ URLs: []string{s.GetLocalRepositoryURL(fixtures.ByTag("tags").One())},
})
s.testFetch(c, r, &FetchOptions{
@@ -101,7 +101,7 @@ 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()),
+ URLs: []string{s.GetLocalRepositoryURL(fixtures.ByTag("tags").One())},
})
ctx, cancel := context.WithCancel(context.Background())
@@ -113,12 +113,11 @@ func (s *RemoteSuite) TestFetchContext(c *C) {
},
})
c.Assert(err, NotNil)
-
}
func (s *RemoteSuite) TestFetchWithAllTags(c *C) {
r := newRemote(memory.NewStorage(), &config.RemoteConfig{
- URL: s.GetLocalRepositoryURL(fixtures.ByTag("tags").One()),
+ URLs: []string{s.GetLocalRepositoryURL(fixtures.ByTag("tags").One())},
})
s.testFetch(c, r, &FetchOptions{
@@ -138,7 +137,7 @@ func (s *RemoteSuite) TestFetchWithAllTags(c *C) {
func (s *RemoteSuite) TestFetchWithNoTags(c *C) {
r := newRemote(memory.NewStorage(), &config.RemoteConfig{
- URL: s.GetLocalRepositoryURL(fixtures.ByTag("tags").One()),
+ URLs: []string{s.GetLocalRepositoryURL(fixtures.ByTag("tags").One())},
})
s.testFetch(c, r, &FetchOptions{
@@ -154,7 +153,7 @@ func (s *RemoteSuite) TestFetchWithNoTags(c *C) {
func (s *RemoteSuite) TestFetchWithDepth(c *C) {
r := newRemote(memory.NewStorage(), &config.RemoteConfig{
- URL: s.GetBasicLocalRepositoryURL(),
+ URLs: []string{s.GetBasicLocalRepositoryURL()},
})
s.testFetch(c, r, &FetchOptions{
@@ -193,7 +192,7 @@ func (s *RemoteSuite) TestFetchWithProgress(c *C) {
sto := memory.NewStorage()
buf := bytes.NewBuffer(nil)
- r := newRemote(sto, &config.RemoteConfig{Name: "foo", URL: url})
+ r := newRemote(sto, &config.RemoteConfig{Name: "foo", URLs: []string{url}})
refspec := config.RefSpec("+refs/heads/*:refs/remotes/origin/*")
err := r.Fetch(&FetchOptions{
@@ -229,7 +228,7 @@ func (s *RemoteSuite) TestFetchWithPackfileWriter(c *C) {
mock := &mockPackfileWriter{Storer: fss}
url := s.GetBasicLocalRepositoryURL()
- r := newRemote(mock, &config.RemoteConfig{Name: "foo", URL: url})
+ r := newRemote(mock, &config.RemoteConfig{Name: "foo", URLs: []string{url}})
refspec := config.RefSpec("+refs/heads/*:refs/remotes/origin/*")
err = r.Fetch(&FetchOptions{
@@ -258,7 +257,7 @@ func (s *RemoteSuite) TestFetchNoErrAlreadyUpToDate(c *C) {
func (s *RemoteSuite) TestFetchNoErrAlreadyUpToDateButStillUpdateLocalRemoteRefs(c *C) {
r := newRemote(memory.NewStorage(), &config.RemoteConfig{
- URL: s.GetBasicLocalRepositoryURL(),
+ URLs: []string{s.GetBasicLocalRepositoryURL()},
})
o := &FetchOptions{
@@ -294,7 +293,7 @@ func (s *RemoteSuite) TestFetchNoErrAlreadyUpToDateWithNonCommitObjects(c *C) {
}
func (s *RemoteSuite) doTestFetchNoErrAlreadyUpToDate(c *C, url string) {
- r := newRemote(memory.NewStorage(), &config.RemoteConfig{URL: url})
+ r := newRemote(memory.NewStorage(), &config.RemoteConfig{URLs: []string{url}})
o := &FetchOptions{
RefSpecs: []config.RefSpec{
@@ -311,7 +310,7 @@ func (s *RemoteSuite) doTestFetchNoErrAlreadyUpToDate(c *C, url string) {
func (s *RemoteSuite) TestString(c *C) {
r := newRemote(nil, &config.RemoteConfig{
Name: "foo",
- URL: "https://github.com/git-fixtures/basic.git",
+ URLs: []string{"https://github.com/git-fixtures/basic.git"},
})
c.Assert(r.String(), Equals, ""+
@@ -331,7 +330,7 @@ func (s *RemoteSuite) TestPushToEmptyRepository(c *C) {
r := newRemote(sto, &config.RemoteConfig{
Name: DefaultRemoteName,
- URL: url,
+ URLs: []string{url},
})
rs := config.RefSpec("refs/heads/*:refs/heads/*")
@@ -345,7 +344,7 @@ func (s *RemoteSuite) TestPushToEmptyRepository(c *C) {
expected := make(map[string]string)
iter.ForEach(func(ref *plumbing.Reference) error {
- if !ref.IsBranch() {
+ if !ref.Name().IsBranch() {
return nil
}
@@ -369,7 +368,7 @@ func (s *RemoteSuite) TestPushContext(c *C) {
r := newRemote(sto, &config.RemoteConfig{
Name: DefaultRemoteName,
- URL: url,
+ URLs: []string{url},
})
ctx, cancel := context.WithCancel(context.Background())
@@ -392,7 +391,7 @@ func (s *RemoteSuite) TestPushTags(c *C) {
r := newRemote(sto, &config.RemoteConfig{
Name: DefaultRemoteName,
- URL: url,
+ URLs: []string{url},
})
err = r.Push(&PushOptions{
@@ -416,7 +415,7 @@ func (s *RemoteSuite) TestPushNoErrAlreadyUpToDate(c *C) {
r := newRemote(sto, &config.RemoteConfig{
Name: DefaultRemoteName,
- URL: fs.Root(),
+ URLs: []string{fs.Root()},
})
err = r.Push(&PushOptions{
@@ -490,7 +489,7 @@ func (s *RemoteSuite) TestPushForce(c *C) {
url := dstFs.Root()
r := newRemote(sto, &config.RemoteConfig{
Name: DefaultRemoteName,
- URL: url,
+ URLs: []string{url},
})
oldRef, err := dstSto.Reference(plumbing.ReferenceName("refs/heads/branch"))
@@ -540,25 +539,25 @@ func (s *RemoteSuite) TestPushNewReference(c *C) {
}
func (s *RemoteSuite) TestPushInvalidEndpoint(c *C) {
- r := newRemote(nil, &config.RemoteConfig{Name: "foo", URL: "http://\\"})
+ r := newRemote(nil, &config.RemoteConfig{Name: "foo", URLs: []string{"http://\\"}})
err := r.Push(&PushOptions{RemoteName: "foo"})
c.Assert(err, ErrorMatches, ".*invalid character.*")
}
func (s *RemoteSuite) TestPushNonExistentEndpoint(c *C) {
- r := newRemote(nil, &config.RemoteConfig{Name: "foo", URL: "ssh://non-existent/foo.git"})
+ r := newRemote(nil, &config.RemoteConfig{Name: "foo", URLs: []string{"ssh://non-existent/foo.git"}})
err := r.Push(&PushOptions{})
c.Assert(err, NotNil)
}
func (s *RemoteSuite) TestPushInvalidSchemaEndpoint(c *C) {
- r := newRemote(nil, &config.RemoteConfig{Name: "origin", URL: "qux://foo"})
+ r := newRemote(nil, &config.RemoteConfig{Name: "origin", URLs: []string{"qux://foo"}})
err := r.Push(&PushOptions{})
c.Assert(err, ErrorMatches, ".*unsupported scheme.*")
}
func (s *RemoteSuite) TestPushInvalidFetchOptions(c *C) {
- r := newRemote(nil, &config.RemoteConfig{Name: "foo", URL: "qux://foo"})
+ r := newRemote(nil, &config.RemoteConfig{Name: "foo", URLs: []string{"qux://foo"}})
invalid := config.RefSpec("^*$ñ")
err := r.Push(&PushOptions{RefSpecs: []config.RefSpec{invalid}})
c.Assert(err, Equals, config.ErrRefSpecMalformedSeparator)
@@ -567,7 +566,7 @@ func (s *RemoteSuite) TestPushInvalidFetchOptions(c *C) {
func (s *RemoteSuite) TestPushInvalidRefSpec(c *C) {
r := newRemote(nil, &config.RemoteConfig{
Name: DefaultRemoteName,
- URL: "some-url",
+ URLs: []string{"some-url"},
})
rs := config.RefSpec("^*$**")
@@ -580,7 +579,7 @@ func (s *RemoteSuite) TestPushInvalidRefSpec(c *C) {
func (s *RemoteSuite) TestPushWrongRemoteName(c *C) {
r := newRemote(nil, &config.RemoteConfig{
Name: DefaultRemoteName,
- URL: "some-url",
+ URLs: []string{"some-url"},
})
err := r.Push(&PushOptions{