MCPcopy Index your code
hub / github.com/go-git/go-git / TestRestoreBoth

Method TestRestoreBoth

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

Source from the content-addressed store, hash-verified

3412}
3413
3414func (s *WorktreeSuite) TestRestoreBoth(c *C) {
3415 _, w, names := setupForRestore(c, s)
3416
3417 // Attempt without files should throw an error like the git restore --staged --worktree
3418 opts := RestoreOptions{Staged: true, Worktree: true}
3419 err := w.Restore(&opts)
3420 c.Assert(err, Equals, ErrNoRestorePaths)
3421
3422 // Restore Staged files in 2 groups and confirm status
3423 opts.Files = []string{names[0], names[1]}
3424 err = w.Restore(&opts)
3425 c.Assert(err, IsNil)
3426 verifyStatus(c, "Restored First", w, names, []FileStatus{
3427 {Worktree: Untracked, Staging: Untracked},
3428 {Worktree: Untracked, Staging: Untracked},
3429 {Worktree: Modified, Staging: Modified},
3430 {Worktree: Unmodified, Staging: Deleted},
3431 })
3432
3433 opts.Files = []string{names[2], names[3]}
3434 err = w.Restore(&opts)
3435 c.Assert(err, IsNil)
3436 verifyStatus(c, "Restored Second", w, names, []FileStatus{
3437 {Worktree: Untracked, Staging: Untracked},
3438 {Worktree: Untracked, Staging: Untracked},
3439 {Worktree: Untracked, Staging: Untracked},
3440 {Worktree: Untracked, Staging: Untracked},
3441 })
3442}
3443
3444func TestFilePermissions(t *testing.T) {
3445 // Initialize an in memory repository

Callers

nothing calls this directly

Calls 3

setupForRestoreFunction · 0.85
verifyStatusFunction · 0.85
RestoreMethod · 0.80

Tested by

no test coverage detected