aboutsummaryrefslogtreecommitdiffstats
path: root/submodule_test.go
diff options
context:
space:
mode:
authorMáximo Cuadros <mcuadros@gmail.com>2017-04-15 23:13:45 +0200
committerMáximo Cuadros <mcuadros@gmail.com>2017-04-15 23:13:45 +0200
commit4b0fc1eb6937b6e5f8569794e8b669443e2c7584 (patch)
tree9f2fdb086be2b96ff9c2169fdb93e19e5a298490 /submodule_test.go
parent601c85a8834cd78e317f1ba435475fa18162053a (diff)
downloadgo-git-4b0fc1eb6937b6e5f8569794e8b669443e2c7584.tar.gz
worktree: reset and checkout support for submodules
Diffstat (limited to 'submodule_test.go')
-rw-r--r--submodule_test.go29
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)
+}