MCPcopy
hub / github.com/go-git/go-git / TestAddUntracked

Method TestAddUntracked

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

Source from the content-addressed store, hash-verified

1616}
1617
1618func (s *WorktreeSuite) TestAddUntracked(c *C) {
1619 fs := memfs.New()
1620 w := &Worktree{
1621 r: s.Repository,
1622 Filesystem: fs,
1623 }
1624
1625 err := w.Checkout(&CheckoutOptions{Force: true})
1626 c.Assert(err, IsNil)
1627
1628 idx, err := w.r.Storer.Index()
1629 c.Assert(err, IsNil)
1630 c.Assert(idx.Entries, HasLen, 9)
1631
1632 err = util.WriteFile(w.Filesystem, "foo", []byte("FOO"), 0755)
1633 c.Assert(err, IsNil)
1634
1635 hash, err := w.Add("foo")
1636 c.Assert(hash.String(), Equals, "d96c7efbfec2814ae0301ad054dc8d9fc416c9b5")
1637 c.Assert(err, IsNil)
1638
1639 idx, err = w.r.Storer.Index()
1640 c.Assert(err, IsNil)
1641 c.Assert(idx.Entries, HasLen, 10)
1642
1643 e, err := idx.Entry("foo")
1644 c.Assert(err, IsNil)
1645 c.Assert(e.Hash, Equals, hash)
1646 c.Assert(e.Mode, Equals, filemode.Executable)
1647
1648 status, err := w.Status()
1649 c.Assert(err, IsNil)
1650 c.Assert(status, HasLen, 1)
1651
1652 file := status.File("foo")
1653 c.Assert(file.Staging, Equals, Added)
1654 c.Assert(file.Worktree, Equals, Unmodified)
1655
1656 obj, err := w.r.Storer.EncodedObject(plumbing.BlobObject, hash)
1657 c.Assert(err, IsNil)
1658 c.Assert(obj, NotNil)
1659 c.Assert(obj.Size(), Equals, int64(3))
1660}
1661
1662func (s *WorktreeSuite) TestIgnored(c *C) {
1663 fs := memfs.New()

Callers

nothing calls this directly

Calls 9

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

Tested by

no test coverage detected