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

Method TestAddSymlink

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

Source from the content-addressed store, hash-verified

1740}
1741
1742func (s *WorktreeSuite) TestAddSymlink(c *C) {
1743 dir, clean := s.TemporalDir()
1744 defer clean()
1745
1746 r, err := PlainInit(dir, false)
1747 c.Assert(err, IsNil)
1748 err = util.WriteFile(r.wt, "foo", []byte("qux"), 0644)
1749 c.Assert(err, IsNil)
1750 err = r.wt.Symlink("foo", "bar")
1751 c.Assert(err, IsNil)
1752
1753 w, err := r.Worktree()
1754 c.Assert(err, IsNil)
1755 h, err := w.Add("foo")
1756 c.Assert(err, IsNil)
1757 c.Assert(h, Not(Equals), plumbing.NewHash("19102815663d23f8b75a47e7a01965dcdc96468c"))
1758
1759 h, err = w.Add("bar")
1760 c.Assert(err, IsNil)
1761 c.Assert(h, Equals, plumbing.NewHash("19102815663d23f8b75a47e7a01965dcdc96468c"))
1762
1763 obj, err := w.r.Storer.EncodedObject(plumbing.BlobObject, h)
1764 c.Assert(err, IsNil)
1765 c.Assert(obj, NotNil)
1766 c.Assert(obj.Size(), Equals, int64(3))
1767}
1768
1769func (s *WorktreeSuite) TestAddDirectory(c *C) {
1770 fs := memfs.New()

Callers

nothing calls this directly

Calls 8

NewHashFunction · 0.92
PlainInitFunction · 0.85
TemporalDirMethod · 0.80
SymlinkMethod · 0.80
WorktreeMethod · 0.80
EncodedObjectMethod · 0.65
SizeMethod · 0.65
AddMethod · 0.45

Tested by

no test coverage detected