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

Method TestAddUntracked

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

Source from the content-addressed store, hash-verified

1416}
1417
1418func (s *WorktreeSuite) TestAddUntracked(c *C) {
1419 fs := memfs.New()
1420 w := &Worktree{
1421 r: s.Repository,
1422 Filesystem: fs,
1423 }
1424
1425 err := w.Checkout(&CheckoutOptions{Force: true})
1426 c.Assert(err, IsNil)
1427
1428 idx, err := w.r.Storer.Index()
1429 c.Assert(err, IsNil)
1430 c.Assert(idx.Entries, HasLen, 9)
1431
1432 err = util.WriteFile(w.Filesystem, "foo", []byte("FOO"), 0755)
1433 c.Assert(err, IsNil)
1434
1435 hash, err := w.Add("foo")
1436 c.Assert(hash.String(), Equals, "d96c7efbfec2814ae0301ad054dc8d9fc416c9b5")
1437 c.Assert(err, IsNil)
1438
1439 idx, err = w.r.Storer.Index()
1440 c.Assert(err, IsNil)
1441 c.Assert(idx.Entries, HasLen, 10)
1442
1443 e, err := idx.Entry("foo")
1444 c.Assert(err, IsNil)
1445 c.Assert(e.Hash, Equals, hash)
1446 c.Assert(e.Mode, Equals, filemode.Executable)
1447
1448 status, err := w.Status()
1449 c.Assert(err, IsNil)
1450 c.Assert(status, HasLen, 1)
1451
1452 file := status.File("foo")
1453 c.Assert(file.Staging, Equals, Added)
1454 c.Assert(file.Worktree, Equals, Unmodified)
1455
1456 obj, err := w.r.Storer.EncodedObject(plumbing.BlobObject, hash)
1457 c.Assert(err, IsNil)
1458 c.Assert(obj, NotNil)
1459 c.Assert(obj.Size(), Equals, int64(3))
1460}
1461
1462func (s *WorktreeSuite) TestIgnored(c *C) {
1463 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