diff --git a/.tests/test_config.py b/.tests/test_config.py new file mode 100644 index 0000000..cbbd23f --- /dev/null +++ b/.tests/test_config.py @@ -0,0 +1,45 @@ +"""Tests for configuration.""" + +import os +from pathlib import Path +import pytest + +from termflow.config import Config +from termflow.utils.config import load_config, get_default_db_path + + +class TestConfig: + """Test configuration management.""" + + def test_config_dir_creation(self, tmp_path, monkeypatch): + """Test config directory creation.""" + monkeypatch.setenv("TERMFLOW_HOME", str(tmp_path / ".termflow")) + config = Config() + assert config.config_dir.exists() + + def test_default_db_path(self, tmp_path, monkeypatch): + """Test default database path.""" + monkeypatch.setenv("TERMFLOW_HOME", str(tmp_path / ".termflow")) + config = Config() + assert "sessions.db" in config.db_path + + def test_git_cache_path(self, tmp_path, monkeypatch): + """Test git cache path.""" + monkeypatch.setenv("TERMFLOW_HOME", str(tmp_path / ".termflow")) + config = Config() + assert "git_cache" in config.git_cache + + +class TestConfigUtils: + """Test configuration utilities.""" + + def test_load_config_missing(self, tmp_path): + """Test loading missing config.""" + result = load_config(str(tmp_path / "missing")) + assert result == {} + + def test_get_default_db_path(self): + """Test default db path generation.""" + path = get_default_db_path() + assert "sessions.db" in path + assert ".termflow" in path