Skip to content

Commit

Permalink
fix: CacheManager creates cache_dir if it doesn't exist
Browse files Browse the repository at this point in the history
  • Loading branch information
fullerzz committed Aug 15, 2024
1 parent 9df8ee6 commit 0e938cb
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/smolvault/cache/cache_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
class CacheManager:
def __init__(self, cache_dir: str) -> None:
self.cache_dir = pathlib.Path(cache_dir)
self.cache_dir.mkdir(exist_ok=True)
logger.info("Created CacheManager with cache directory %s", self.cache_dir)

def file_exists(self, filename: str) -> bool:
Expand Down
17 changes: 17 additions & 0 deletions tests/test_cache_manager.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
from pathlib import Path

from smolvault.cache.cache_manager import CacheManager


def test_create_cache_manager_dir_not_exists(tmp_path: Path) -> None:
cache_dir = tmp_path / "cache"
cache_mgr = CacheManager(cache_dir.as_posix())
assert cache_mgr.cache_dir == cache_dir
assert cache_mgr.cache_dir.exists()


def test_create_cache_manager_dir__exists(tmp_path: Path) -> None:
cache_dir = tmp_path / "existing_cache"
cache_dir.mkdir()
cache_mgr = CacheManager(cache_dir.as_posix())
assert cache_mgr.cache_dir == cache_dir

0 comments on commit 0e938cb

Please sign in to comment.