| 356 | } |
| 357 | |
| 358 | func (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 | |
| 386 | func (s *WorktreeSuite) TestCheckoutForce(c *C) { |
| 387 | w := &Worktree{ |