aboutsummaryrefslogtreecommitdiffstats
path: root/worktree_test.go
diff options
context:
space:
mode:
authorMáximo Cuadros <mcuadros@gmail.com>2017-01-27 17:46:46 +0100
committerMáximo Cuadros <mcuadros@gmail.com>2017-01-28 00:42:22 +0100
commit24c1878260351d9f9f6c575cbeeb5878104d6a0e (patch)
treec6a9575aa84197f7f33515ca4d55816134d1569b /worktree_test.go
parent1c2602a791371e76d52f89b2c8193cb200c66ad6 (diff)
downloadgo-git-24c1878260351d9f9f6c575cbeeb5878104d6a0e.tar.gz
new repository constructors and worktree
Diffstat (limited to 'worktree_test.go')
-rw-r--r--worktree_test.go39
1 files changed, 39 insertions, 0 deletions
diff --git a/worktree_test.go b/worktree_test.go
new file mode 100644
index 0000000..9c5d8e3
--- /dev/null
+++ b/worktree_test.go
@@ -0,0 +1,39 @@
+package git
+
+import (
+ "io/ioutil"
+
+ . "gopkg.in/check.v1"
+ "srcd.works/go-billy.v1/memory"
+)
+
+type WorktreeSuite struct {
+ BaseSuite
+}
+
+var _ = Suite(&WorktreeSuite{})
+
+func (s *WorktreeSuite) TestCheckout(c *C) {
+ h, err := s.Repository.Head()
+ c.Assert(err, IsNil)
+
+ fs := memory.New()
+ w := &Worktree{
+ r: s.Repository,
+ fs: fs,
+ }
+
+ err = w.Checkout(h.Hash())
+ c.Assert(err, IsNil)
+
+ entries, err := fs.ReadDir("/")
+ c.Assert(err, IsNil)
+
+ c.Assert(entries, HasLen, 8)
+ ch, err := fs.Open("CHANGELOG")
+ c.Assert(err, IsNil)
+
+ content, err := ioutil.ReadAll(ch)
+ c.Assert(err, IsNil)
+ c.Assert(string(content), Equals, "Initial changelog\n")
+}