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

Method TestCheckout

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

Source from the content-addressed store, hash-verified

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