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

Method TestAddRemoved

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

Source from the content-addressed store, hash-verified

1571}
1572
1573func (s *WorktreeSuite) TestAddRemoved(c *C) {
1574 fs := memfs.New()
1575 w := &Worktree{
1576 r: s.Repository,
1577 Filesystem: fs,
1578 }
1579
1580 err := w.Checkout(&CheckoutOptions{Force: true})
1581 c.Assert(err, IsNil)
1582
1583 idx, err := w.r.Storer.Index()
1584 c.Assert(err, IsNil)
1585 c.Assert(idx.Entries, HasLen, 9)
1586
1587 err = w.Filesystem.Remove("LICENSE")
1588 c.Assert(err, IsNil)
1589
1590 hash, err := w.Add("LICENSE")
1591 c.Assert(err, IsNil)
1592 c.Assert(hash.String(), Equals, "c192bd6a24ea1ab01d78686e417c8bdc7c3d197f")
1593
1594 e, err := idx.Entry("LICENSE")
1595 c.Assert(err, IsNil)
1596 c.Assert(e.Hash, Equals, hash)
1597 c.Assert(e.Mode, Equals, filemode.Regular)
1598
1599 status, err := w.Status()
1600 c.Assert(err, IsNil)
1601 c.Assert(status, HasLen, 1)
1602
1603 file := status.File("LICENSE")
1604 c.Assert(file.Staging, Equals, Deleted)
1605}
1606
1607func (s *WorktreeSuite) TestAddRemovedInDirectory(c *C) {
1608 fs := memfs.New()

Callers

nothing calls this directly

Calls 8

CheckoutMethod · 0.95
AddMethod · 0.95
StatusMethod · 0.95
EntryMethod · 0.80
IndexMethod · 0.65
StringMethod · 0.65
RemoveMethod · 0.45
FileMethod · 0.45

Tested by

no test coverage detected