Skip to content

Commit

Permalink
Merge pull request #24 from nikromen/fix-navigate
Browse files Browse the repository at this point in the history
Fix(navigate): save the path you are returning from to the stack
  • Loading branch information
nikromen authored Aug 26, 2022
2 parents 39f6e0f + 42fa177 commit 8f51478
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
3 changes: 2 additions & 1 deletion dirstory/cli/navigate.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import os
from pathlib import Path
from typing import Optional

Expand All @@ -15,7 +16,7 @@ def back_or_forward(
if curr_path is None:
break

file_stack.push(path=curr_path, is_forward=not is_forward)
file_stack.push(path=Path(os.getcwd()), is_forward=not is_forward)

return curr_path

Expand Down
6 changes: 5 additions & 1 deletion test/unit/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,20 @@ class TestNavigate:
pytest.param(3, False, Path("/here\n")),
],
)
@patch("os.getcwd")
@patch.object(FileStack, "pop")
@patch.object(FileStack, "push")
def test_back_or_forward(self, mock_push, mock_pop, size, is_forward, expected):
def test_back_or_forward(
self, mock_push, mock_pop, mock_getcwd, size, is_forward, expected
):
mocked_pop_ret_vals = [
Path("/some\n"),
Path("/path\n"),
Path("/here\n"),
Path("/dragon\n"),
]
mock_pop.side_effect = mocked_pop_ret_vals
mock_getcwd.side_effect = mocked_pop_ret_vals

result = back_or_forward(FileStack(ppid=123), size, is_forward)

Expand Down

0 comments on commit 8f51478

Please sign in to comment.