| 354 | } |
| 355 | |
| 356 | func (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 | |
| 384 | func (s *WorktreeSuite) TestCheckoutForce(c *C) { |
| 385 | w := &Worktree{ |