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

Method TestCheckout

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

Source from the content-addressed store, hash-verified

354}
355
356func (s *WorktreeSuite) TestCheckout(c *C) {
357 fs := memfs.New()
358 w := &Worktree{
359 r: s.Repository,
360 Filesystem: fs,
361 }
362
363 err := w.Checkout(&CheckoutOptions{
364 Force: true,
365 })
366 c.Assert(err, IsNil)
367
368 entries, err := fs.ReadDir("/")
369 c.Assert(err, IsNil)
370
371 c.Assert(entries, HasLen, 8)
372 ch, err := fs.Open("CHANGELOG")
373 c.Assert(err, IsNil)
374
375 content, err := io.ReadAll(ch)
376 c.Assert(err, IsNil)
377 c.Assert(string(content), Equals, "Initial changelog\n")
378
379 idx, err := s.Repository.Storer.Index()
380 c.Assert(err, IsNil)
381 c.Assert(idx.Entries, HasLen, 9)
382}
383
384func (s *WorktreeSuite) TestCheckoutForce(c *C) {
385 w := &Worktree{

Callers

nothing calls this directly

Calls 4

CheckoutMethod · 0.95
IndexMethod · 0.65
ReadDirMethod · 0.45
OpenMethod · 0.45

Tested by

no test coverage detected