diff options
author | Máximo Cuadros <mcuadros@gmail.com> | 2017-02-21 16:07:25 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-02-21 16:07:25 +0100 |
commit | 867b10692e5f8a34a82cc0a783bdb63e2b5ff398 (patch) | |
tree | 3ddb2f430ee3c958f0650cb7db6a9df44b1e1361 /config/config_test.go | |
parent | 0b8b8da617d5a077f282e57d0300dc106a604236 (diff) | |
parent | 790fbdaddc3c9a434f2ad97d9eb56db9b6c99495 (diff) | |
download | go-git-867b10692e5f8a34a82cc0a783bdb63e2b5ff398.tar.gz |
Merge pull request #270 from mcuadros/submodules-init
Submodules init and update
Diffstat (limited to 'config/config_test.go')
-rw-r--r-- | config/config_test.go | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/config/config_test.go b/config/config_test.go index 2bcefe4..cfab36d 100644 --- a/config/config_test.go +++ b/config/config_test.go @@ -9,9 +9,14 @@ var _ = Suite(&ConfigSuite{}) func (s *ConfigSuite) TestUnmarshall(c *C) { input := []byte(`[core] bare = true + worktree = foo [remote "origin"] url = git@github.com:mcuadros/go-git.git fetch = +refs/heads/*:refs/remotes/origin/* +[submodule "qux"] + path = qux + url = https://github.com/foo/qux.git + branch = bar [branch "master"] remote = origin merge = refs/heads/master @@ -22,15 +27,51 @@ func (s *ConfigSuite) TestUnmarshall(c *C) { c.Assert(err, IsNil) c.Assert(cfg.Core.IsBare, Equals, true) + c.Assert(cfg.Core.Worktree, Equals, "foo") c.Assert(cfg.Remotes, HasLen, 1) 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"].Fetch, DeepEquals, []RefSpec{"+refs/heads/*:refs/remotes/origin/*"}) + 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") + c.Assert(cfg.Submodules["qux"].Branch, Equals, "bar") + +} + +func (s *ConfigSuite) TestMarshall(c *C) { + output := []byte(`[core] + bare = true + worktree = bar +[remote "origin"] + url = git@github.com:mcuadros/go-git.git +[submodule "qux"] + url = https://github.com/foo/qux.git +`) + + cfg := NewConfig() + cfg.Core.IsBare = true + cfg.Core.Worktree = "bar" + cfg.Remotes["origin"] = &RemoteConfig{ + Name: "origin", + URL: "git@github.com:mcuadros/go-git.git", + } + + cfg.Submodules["qux"] = &Submodule{ + Name: "qux", + URL: "https://github.com/foo/qux.git", + } + + b, err := cfg.Marshal() + c.Assert(err, IsNil) + + c.Assert(string(b), Equals, string(output)) } func (s *ConfigSuite) TestUnmarshallMarshall(c *C) { input := []byte(`[core] bare = true + worktree = foo custom = ignored [remote "origin"] url = git@github.com:mcuadros/go-git.git |