diff options
author | Sunny <me@darkowlzz.space> | 2017-12-04 20:44:00 +0530 |
---|---|---|
committer | Sunny <me@darkowlzz.space> | 2017-12-04 20:44:00 +0530 |
commit | d43f17481253b76b558bfe4cc1e1b17bfb0c74e4 (patch) | |
tree | a953de57c09da6ddb8c66e52259ddec08ee2bea7 /worktree_test.go | |
parent | e7b02be89f2d98fcfe900d71b3b7ecdca8441ed2 (diff) | |
download | go-git-d43f17481253b76b558bfe4cc1e1b17bfb0c74e4.tar.gz |
test: git, Worktree.Clean()
Diffstat (limited to 'worktree_test.go')
-rw-r--r-- | worktree_test.go | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/worktree_test.go b/worktree_test.go index 1bdf946..46c1faa 100644 --- a/worktree_test.go +++ b/worktree_test.go @@ -1252,3 +1252,38 @@ func (s *WorktreeSuite) TestMoveToExistent(c *C) { c.Assert(hash.IsZero(), Equals, true) c.Assert(err, Equals, ErrDestinationExists) } + +func (s *WorktreeSuite) TestClean(c *C) { + fs := fixtures.ByTag("dirty").One().Worktree() + + // Open the repo. + fs, err := fs.Chroot("repo") + c.Assert(err, IsNil) + r, err := PlainOpen(fs.Root()) + c.Assert(err, IsNil) + + wt, err := r.Worktree() + c.Assert(err, IsNil) + + // Status before cleaning. + status, err := wt.Status() + c.Assert(len(status), Equals, 2) + + err = wt.Clean(&CleanOptions{}) + c.Assert(err, IsNil) + + // Status after cleaning. + status, err = wt.Status() + c.Assert(err, IsNil) + + c.Assert(len(status), Equals, 1) + + // Clean with Dir: true. + err = wt.Clean(&CleanOptions{Dir: true}) + c.Assert(err, IsNil) + + status, err = wt.Status() + c.Assert(err, IsNil) + + c.Assert(len(status), Equals, 0) +} |