aboutsummaryrefslogtreecommitdiffstats
path: root/config/config_test.go
diff options
context:
space:
mode:
authorSantiago M. Mola <santi@mola.io>2017-07-24 10:51:01 +0200
committerSantiago M. Mola <santi@mola.io>2017-08-01 13:01:54 +0200
commit9488c59834f6a2591910b7b360721cec2c16c548 (patch)
treefea051f6cf08a62aad12e32b2240aa837be22628 /config/config_test.go
parent7b08a3005480a50f0f4290aff8f3702085d5e30d (diff)
downloadgo-git-9488c59834f6a2591910b7b360721cec2c16c548.tar.gz
config: multiple values in RemoteConfig (URLs and Fetch)
* Change `URL string` to `URL []string` in `RemoteConfig`, since git allows multiple URLs per remote. See: http://marc.info/?l=git&m=116231242118202&w=2 * Fix marshalling of multiple fetch refspecs.
Diffstat (limited to 'config/config_test.go')
-rw-r--r--config/config_test.go27
1 files changed, 23 insertions, 4 deletions
diff --git a/config/config_test.go b/config/config_test.go
index cfab36d..e958677 100644
--- a/config/config_test.go
+++ b/config/config_test.go
@@ -13,6 +13,11 @@ func (s *ConfigSuite) TestUnmarshall(c *C) {
[remote "origin"]
url = git@github.com:mcuadros/go-git.git
fetch = +refs/heads/*:refs/remotes/origin/*
+[remote "alt"]
+ url = git@github.com:mcuadros/go-git.git
+ url = git@github.com:src-d/go-git.git
+ fetch = +refs/heads/*:refs/remotes/origin/*
+ fetch = +refs/pull/*:refs/remotes/origin/pull/*
[submodule "qux"]
path = qux
url = https://github.com/foo/qux.git
@@ -28,10 +33,13 @@ func (s *ConfigSuite) TestUnmarshall(c *C) {
c.Assert(cfg.Core.IsBare, Equals, true)
c.Assert(cfg.Core.Worktree, Equals, "foo")
- c.Assert(cfg.Remotes, HasLen, 1)
+ c.Assert(cfg.Remotes, HasLen, 2)
c.Assert(cfg.Remotes["origin"].Name, Equals, "origin")
- c.Assert(cfg.Remotes["origin"].URL, Equals, "git@github.com:mcuadros/go-git.git")
+ c.Assert(cfg.Remotes["origin"].URLs, DeepEquals, []string{"git@github.com:mcuadros/go-git.git"})
c.Assert(cfg.Remotes["origin"].Fetch, DeepEquals, []RefSpec{"+refs/heads/*:refs/remotes/origin/*"})
+ c.Assert(cfg.Remotes["alt"].Name, Equals, "alt")
+ c.Assert(cfg.Remotes["alt"].URLs, DeepEquals, []string{"git@github.com:mcuadros/go-git.git", "git@github.com:src-d/go-git.git"})
+ c.Assert(cfg.Remotes["alt"].Fetch, DeepEquals, []RefSpec{"+refs/heads/*:refs/remotes/origin/*", "+refs/pull/*:refs/remotes/origin/pull/*"})
c.Assert(cfg.Submodules, HasLen, 1)
c.Assert(cfg.Submodules["qux"].Name, Equals, "qux")
c.Assert(cfg.Submodules["qux"].URL, Equals, "https://github.com/foo/qux.git")
@@ -45,6 +53,11 @@ func (s *ConfigSuite) TestMarshall(c *C) {
worktree = bar
[remote "origin"]
url = git@github.com:mcuadros/go-git.git
+[remote "alt"]
+ url = git@github.com:mcuadros/go-git.git
+ url = git@github.com:src-d/go-git.git
+ fetch = +refs/heads/*:refs/remotes/origin/*
+ fetch = +refs/pull/*:refs/remotes/origin/pull/*
[submodule "qux"]
url = https://github.com/foo/qux.git
`)
@@ -54,7 +67,13 @@ func (s *ConfigSuite) TestMarshall(c *C) {
cfg.Core.Worktree = "bar"
cfg.Remotes["origin"] = &RemoteConfig{
Name: "origin",
- URL: "git@github.com:mcuadros/go-git.git",
+ URLs: []string{"git@github.com:mcuadros/go-git.git"},
+ }
+
+ cfg.Remotes["alt"] = &RemoteConfig{
+ Name: "alt",
+ URLs: []string{"git@github.com:mcuadros/go-git.git", "git@github.com:src-d/go-git.git"},
+ Fetch: []RefSpec{"+refs/heads/*:refs/remotes/origin/*", "+refs/pull/*:refs/remotes/origin/pull/*"},
}
cfg.Submodules["qux"] = &Submodule{
@@ -122,7 +141,7 @@ func (s *ConfigSuite) TestRemoteConfigValidateMissingName(c *C) {
}
func (s *ConfigSuite) TestRemoteConfigValidateDefault(c *C) {
- config := &RemoteConfig{Name: "foo", URL: "http://foo/bar"}
+ config := &RemoteConfig{Name: "foo", URLs: []string{"http://foo/bar"}}
c.Assert(config.Validate(), IsNil)
fetch := config.Fetch