mirror of
https://github.com/himanshudongre/smriti.git
synced 2026-08-28 05:14:59 +00:00
Adds WorkTree schema and migration, /api/v5/worktrees CRUD, CLI and MCP worktree surfaces, targeted regression tests, health capability, and minimal docs. Live Postgres migration/manual localhost verification intentionally remain pending until the full backend provider-config gate is resolved.
33 lines
983 B
Python
33 lines
983 B
Python
"""Unit tests for worktree naming/path helpers."""
|
|
from __future__ import annotations
|
|
|
|
from pathlib import Path
|
|
|
|
from app.api.routes import worktrees
|
|
|
|
|
|
def test_slugify_lowercases_and_replaces_non_alphanumeric():
|
|
assert worktrees._slugify("Smriti Dev!") == "smriti-dev"
|
|
assert worktrees._slugify("Claude_Code v2") == "claude-code-v2"
|
|
assert worktrees._slugify("!!!", fallback="fallback") == "fallback"
|
|
|
|
|
|
def test_default_branch_name_uses_agent_slug():
|
|
assert (
|
|
worktrees._default_branch_name("Claude Code", "abc12345")
|
|
== "smriti/claude-code/abc12345"
|
|
)
|
|
|
|
|
|
def test_default_worktree_path_uses_home_space_agent_and_suffix(monkeypatch, tmp_path):
|
|
monkeypatch.setattr(worktrees.Path, "home", lambda: Path(tmp_path))
|
|
|
|
path = worktrees._default_worktree_path(
|
|
"Smriti Dev",
|
|
"Codex Local",
|
|
"abc12345",
|
|
)
|
|
|
|
assert path == str(
|
|
tmp_path / ".smriti" / "worktrees" / "smriti-dev" / "codex-local-abc12345"
|
|
)
|