diff options
author | Máximo Cuadros <mcuadros@gmail.com> | 2017-04-17 17:36:28 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-04-17 17:36:28 +0200 |
commit | c991d2d1c2253ac246441bc92bf97804a73c0bf2 (patch) | |
tree | 9a6965fb0023262ea17d02bcedd9f48204a80750 /submodule_test.go | |
parent | 057f1dd4fa44df509cb96977c0a8193407a22767 (diff) | |
parent | 4b0fc1eb6937b6e5f8569794e8b669443e2c7584 (diff) | |
download | go-git-c991d2d1c2253ac246441bc92bf97804a73c0bf2.tar.gz |
Merge pull request #344 from mcuadros/submodules-checkout
worktree: reset and checkout support for submodules
Diffstat (limited to 'submodule_test.go')
-rw-r--r-- | submodule_test.go | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/submodule_test.go b/submodule_test.go index 88afa18..6e06191 100644 --- a/submodule_test.go +++ b/submodule_test.go @@ -48,14 +48,21 @@ func (s *SubmoduleSuite) TestInit(c *C) { sm, err := s.Worktree.Submodule("basic") c.Assert(err, IsNil) + c.Assert(sm.initialized, Equals, false) err = sm.Init() c.Assert(err, IsNil) + c.Assert(sm.initialized, Equals, true) + cfg, err := s.Repository.Config() c.Assert(err, IsNil) c.Assert(cfg.Submodules, HasLen, 1) c.Assert(cfg.Submodules["basic"], NotNil) + + status, err := sm.Status() + c.Assert(err, IsNil) + c.Assert(status.IsClean(), Equals, false) } func (s *SubmoduleSuite) TestUpdate(c *C) { @@ -74,6 +81,19 @@ func (s *SubmoduleSuite) TestUpdate(c *C) { ref, err := r.Reference(plumbing.HEAD, true) c.Assert(err, IsNil) c.Assert(ref.Hash().String(), Equals, "6ecf0ef2c2dffb796033e5a02219af86ec6584e5") + + status, err := sm.Status() + c.Assert(err, IsNil) + c.Assert(status.IsClean(), Equals, true) +} + +func (s *SubmoduleSuite) TestRepositoryWithoutInit(c *C) { + sm, err := s.Worktree.Submodule("basic") + c.Assert(err, IsNil) + + r, err := sm.Repository() + c.Assert(err, Equals, ErrSubmoduleNotInitialized) + c.Assert(r, IsNil) } func (s *SubmoduleSuite) TestUpdateWithoutInit(c *C) { @@ -161,3 +181,12 @@ func (s *SubmoduleSuite) TestSubmodulesInit(c *C) { c.Assert(m.initialized, Equals, true) } } + +func (s *SubmoduleSuite) TestSubmodulesStatus(c *C) { + sm, err := s.Worktree.Submodules() + c.Assert(err, IsNil) + + status, err := sm.Status() + c.Assert(err, IsNil) + c.Assert(status, HasLen, 2) +} |