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

Method TestAddModified

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

Source from the content-addressed store, hash-verified

1517}
1518
1519func (s *WorktreeSuite) TestAddModified(c *C) {
1520 fs := memfs.New()
1521 w := &Worktree{
1522 r: s.Repository,
1523 Filesystem: fs,
1524 }
1525
1526 err := w.Checkout(&CheckoutOptions{Force: true})
1527 c.Assert(err, IsNil)
1528
1529 idx, err := w.r.Storer.Index()
1530 c.Assert(err, IsNil)
1531 c.Assert(idx.Entries, HasLen, 9)
1532
1533 err = util.WriteFile(w.Filesystem, "LICENSE", []byte("FOO"), 0644)
1534 c.Assert(err, IsNil)
1535
1536 hash, err := w.Add("LICENSE")
1537 c.Assert(err, IsNil)
1538 c.Assert(hash.String(), Equals, "d96c7efbfec2814ae0301ad054dc8d9fc416c9b5")
1539
1540 idx, err = w.r.Storer.Index()
1541 c.Assert(err, IsNil)
1542 c.Assert(idx.Entries, HasLen, 9)
1543
1544 e, err := idx.Entry("LICENSE")
1545 c.Assert(err, IsNil)
1546 c.Assert(e.Hash, Equals, hash)
1547 c.Assert(e.Mode, Equals, filemode.Regular)
1548
1549 status, err := w.Status()
1550 c.Assert(err, IsNil)
1551 c.Assert(status, HasLen, 1)
1552
1553 file := status.File("LICENSE")
1554 c.Assert(file.Staging, Equals, Modified)
1555 c.Assert(file.Worktree, Equals, Unmodified)
1556}
1557
1558func (s *WorktreeSuite) TestAddUnmodified(c *C) {
1559 fs := memfs.New()

Callers

nothing calls this directly

Calls 7

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

Tested by

no test coverage detected