MCPcopy Create free account
hub / github.com/go-git/go-git / TestAddDirectory

Method TestAddDirectory

worktree_test.go:1769–1815  ·  view source on GitHub ↗
(c *C)

Source from the content-addressed store, hash-verified

1767}
1768
1769func (s *WorktreeSuite) TestAddDirectory(c *C) {
1770 fs := memfs.New()
1771 w := &Worktree{
1772 r: s.Repository,
1773 Filesystem: fs,
1774 }
1775
1776 err := w.Checkout(&CheckoutOptions{Force: true})
1777 c.Assert(err, IsNil)
1778
1779 idx, err := w.r.Storer.Index()
1780 c.Assert(err, IsNil)
1781 c.Assert(idx.Entries, HasLen, 9)
1782
1783 err = util.WriteFile(w.Filesystem, "qux/foo", []byte("FOO"), 0755)
1784 c.Assert(err, IsNil)
1785 err = util.WriteFile(w.Filesystem, "qux/baz/bar", []byte("BAR"), 0755)
1786 c.Assert(err, IsNil)
1787
1788 h, err := w.Add("qux")
1789 c.Assert(err, IsNil)
1790 c.Assert(h.IsZero(), Equals, true)
1791
1792 idx, err = w.r.Storer.Index()
1793 c.Assert(err, IsNil)
1794 c.Assert(idx.Entries, HasLen, 11)
1795
1796 e, err := idx.Entry("qux/foo")
1797 c.Assert(err, IsNil)
1798 c.Assert(e.Mode, Equals, filemode.Executable)
1799
1800 e, err = idx.Entry("qux/baz/bar")
1801 c.Assert(err, IsNil)
1802 c.Assert(e.Mode, Equals, filemode.Executable)
1803
1804 status, err := w.Status()
1805 c.Assert(err, IsNil)
1806 c.Assert(status, HasLen, 2)
1807
1808 file := status.File("qux/foo")
1809 c.Assert(file.Staging, Equals, Added)
1810 c.Assert(file.Worktree, Equals, Unmodified)
1811
1812 file = status.File("qux/baz/bar")
1813 c.Assert(file.Staging, Equals, Added)
1814 c.Assert(file.Worktree, Equals, Unmodified)
1815}
1816
1817func (s *WorktreeSuite) TestAddDirectoryErrorNotFound(c *C) {
1818 r, _ := Init(memory.NewStorage(), memfs.New())

Callers

nothing calls this directly

Calls 7

CheckoutMethod · 0.95
AddMethod · 0.95
StatusMethod · 0.95
EntryMethod · 0.80
IndexMethod · 0.65
IsZeroMethod · 0.65
FileMethod · 0.45

Tested by

no test coverage detected