From bb29325f57cabb280e86c35189a2d6b71f04f6b7 Mon Sep 17 00:00:00 2001 From: 7000pctAUTO Date: Sun, 22 Mar 2026 18:15:39 +0000 Subject: [PATCH] Initial upload: shell-history-semantic-search v0.1.0 --- tests/conftest.py | 68 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 tests/conftest.py diff --git a/tests/conftest.py b/tests/conftest.py new file mode 100644 index 0000000..c312d5a --- /dev/null +++ b/tests/conftest.py @@ -0,0 +1,68 @@ +import pytest +import tempfile +import os +from pathlib import Path + + +@pytest.fixture +def temp_home(monkeypatch): + with tempfile.TemporaryDirectory() as tmpdir: + home = Path(tmpdir) + monkeypatch.setenv("HOME", str(home)) + yield home + + +@pytest.fixture +def temp_db_path(temp_home): + db_dir = temp_home / ".local" / "share" / "shell_history_search" + db_dir.mkdir(parents=True, exist_ok=True) + return db_dir / "history.db" + + +@pytest.fixture +def temp_cache_dir(temp_home): + cache_dir = temp_home / ".cache" / "shell_history_search" / "models" + cache_dir.mkdir(parents=True, exist_ok=True) + return cache_dir + + +@pytest.fixture +def sample_bash_history(temp_home): + history_file = temp_home / ".bash_history" + history_file.write_text(""" +git add . +git commit -m "Initial commit" +git push origin main +docker build -t myapp . +docker run -p 8080:8080 myapp +ls -la +cat /etc/os-release + """.strip()) + return history_file + + +@pytest.fixture +def sample_zsh_history(temp_home): + history_file = temp_home / ".zsh_history" + history_file.write_text(""" +: 1700000000:0;git pull origin main +: 1700000001:0;docker ps +: 1700000002:0;npm run build +: 1700000003:0;pytest tests/ -v + """.strip()) + return history_file + + +@pytest.fixture +def sample_fish_history(temp_home): + history_file = temp_home / ".local" / "share" / "fish" / "fish_history" + history_file.parent.mkdir(parents=True, exist_ok=True) + history_file.write_text(""" +- 1700000000 +cmd docker-compose up -d +- 1700000001 +cmd cargo build --release +- 1700000002 +cmd curl localhost:8080/api/health + """.strip()) + return history_file \ No newline at end of file