MCPcopy Index your code
hub / github.com/go-git/go-git / TestAddDirectory

Method TestAddDirectory

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

Source from the content-addressed store, hash-verified

1966}
1967
1968func (s *WorktreeSuite) TestAddDirectory(c *C) {
1969 fs := memfs.New()
1970 w := &Worktree{
1971 r: s.Repository,
1972 Filesystem: fs,
1973 }
1974
1975 err := w.Checkout(&CheckoutOptions{Force: true})
1976 c.Assert(err, IsNil)
1977
1978 idx, err := w.r.Storer.Index()
1979 c.Assert(err, IsNil)
1980 c.Assert(idx.Entries, HasLen, 9)
1981
1982 err = util.WriteFile(w.Filesystem, "qux/foo", []byte("FOO"), 0755)
1983 c.Assert(err, IsNil)
1984 err = util.WriteFile(w.Filesystem, "qux/baz/bar", []byte("BAR"), 0755)
1985 c.Assert(err, IsNil)
1986
1987 h, err := w.Add("qux")
1988 c.Assert(err, IsNil)
1989 c.Assert(h.IsZero(), Equals, true)
1990
1991 idx, err = w.r.Storer.Index()
1992 c.Assert(err, IsNil)
1993 c.Assert(idx.Entries, HasLen, 11)
1994
1995 e, err := idx.Entry("qux/foo")
1996 c.Assert(err, IsNil)
1997 c.Assert(e.Mode, Equals, filemode.Executable)
1998
1999 e, err = idx.Entry("qux/baz/bar")
2000 c.Assert(err, IsNil)
2001 c.Assert(e.Mode, Equals, filemode.Executable)
2002
2003 status, err := w.Status()
2004 c.Assert(err, IsNil)
2005 c.Assert(status, HasLen, 2)
2006
2007 file := status.File("qux/foo")
2008 c.Assert(file.Staging, Equals, Added)
2009 c.Assert(file.Worktree, Equals, Unmodified)
2010
2011 file = status.File("qux/baz/bar")
2012 c.Assert(file.Staging, Equals, Added)
2013 c.Assert(file.Worktree, Equals, Unmodified)
2014}
2015
2016func (s *WorktreeSuite) TestAddDirectoryErrorNotFound(c *C) {
2017 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