aboutsummaryrefslogtreecommitdiffstats
path: root/config/config_test.go
diff options
context:
space:
mode:
authorMáximo Cuadros <mcuadros@gmail.com>2017-08-02 08:12:44 +0200
committerGitHub <noreply@github.com>2017-08-02 08:12:44 +0200
commit9befb514d83e22268d00ab2c0fdd797b3742f0e9 (patch)
tree923a78009cce4531912b92e1b756a6a8f3ee6d32 /config/config_test.go
parent91cdedae7faffca0a707fa47780efafe157ba47c (diff)
parente5c6fa237776870483cbe227d7f7ea943f35cb12 (diff)
downloadgo-git-9befb514d83e22268d00ab2c0fdd797b3742f0e9.tar.gz
Merge pull request #501 from smola/config-multiple-urls
config: multiple values in RemoteConfig (URLs and Fetch)
Diffstat (limited to 'config/config_test.go')
-rw-r--r--config/config_test.go29
1 files changed, 24 insertions, 5 deletions
diff --git a/config/config_test.go b/config/config_test.go
index cfab36d..97f4bbf 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{
@@ -88,7 +107,7 @@ func (s *ConfigSuite) TestUnmarshallMarshall(c *C) {
output, err := cfg.Marshal()
c.Assert(err, IsNil)
- c.Assert(output, DeepEquals, input)
+ c.Assert(string(output), DeepEquals, string(input))
}
func (s *ConfigSuite) TestValidateInvalidRemote(c *C) {
@@ -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