Skip to content

Commit

Permalink
refactor: Improve cross-platform path handling in subtree command tests
Browse files Browse the repository at this point in the history
  • Loading branch information
golergka committed Jan 18, 2025
1 parent 2708e18 commit 1a86645
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions tests/basic/test_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -1184,8 +1184,9 @@ def test_cmd_subtree_relative_path(self):

# Test with relative path
with mock.patch.object(io, "tool_output") as mock_output:
commands.cmd_subtree("dir1/dir2")
mock_output.assert_called_with("Changed subtree path to: dir1/dir2")
commands.cmd_subtree(os.path.join("dir1", "dir2"))
expected_path = os.path.normpath("dir1/dir2")
mock_output.assert_called_with(f"Changed subtree path to: {expected_path}")

def test_cmd_subtree_no_repo(self):
"""Test /subtree with no git repo"""
Expand Down Expand Up @@ -1219,9 +1220,13 @@ def test_cmd_subtree_outside_repo(self):
coder = Coder.create(self.GPT35, None, io, repo=repo)
commands = Commands(io, coder)

# Create a path that's definitely outside the repo
outside_path = os.path.abspath(os.path.join(repo_dir, "..", "outside"))
os.makedirs(outside_path, exist_ok=True)

# Try to set path outside repo
with mock.patch.object(io, "tool_error") as mock_error:
commands.cmd_subtree("/tmp")
commands.cmd_subtree(outside_path)
mock_error.assert_called_with("The path must be within the git repo.")

def test_cmd_test_unbound_local_error(self):
Expand Down

0 comments on commit 1a86645

Please sign in to comment.