Initial upload: shell-history-semantic-search v0.1.0
Some checks failed
CI / test (push) Has been cancelled
Some checks failed
CI / test (push) Has been cancelled
This commit is contained in:
68
tests/conftest.py
Normal file
68
tests/conftest.py
Normal file
@@ -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
|
||||
Reference in New Issue
Block a user