File tree Expand file tree Collapse file tree 2 files changed +12
-11
lines changed Expand file tree Collapse file tree 2 files changed +12
-11
lines changed Original file line number Diff line number Diff line change 1212class CacheManager :
1313 """Manages local caching of GitHub data using SQLite."""
1414
15- CACHE_DIR = Path .home () / ".local" / "share" / "gitfetch"
16- DB_FILE = CACHE_DIR / "cache.db"
17-
18- def __init__ (self , cache_expiry_minutes : int = 15 ):
15+ def __init__ (self , cache_expiry_minutes : int = 15 ,
16+ cache_dir : Optional [Path ] = None ):
1917 """
2018 Initialize the cache manager.
2119
2220 Args:
2321 cache_expiry_minutes: Minutes before cache expires (default: 15)
22+ cache_dir: Directory to store cache files
23+ (default: ~/.local/share/gitfetch)
2424 """
2525 self .cache_expiry_minutes = cache_expiry_minutes
26+ self .CACHE_DIR = cache_dir or (
27+ Path .home () / ".local" / "share" / "gitfetch" )
28+ self .DB_FILE = self .CACHE_DIR / "cache.db"
2629 self ._ensure_cache_dir ()
2730 self ._init_database ()
2831
Original file line number Diff line number Diff line change @@ -15,9 +15,8 @@ class TestCacheManager:
1515 def setup_method (self ):
1616 """Set up test fixtures."""
1717 self .temp_dir = tempfile .mkdtemp ()
18- with patch ('src.gitfetch.cache.CacheManager.CACHE_DIR' ,
19- Path (self .temp_dir )):
20- self .cache_manager = CacheManager (cache_expiry_minutes = 15 )
18+ self .cache_manager = CacheManager (
19+ cache_expiry_minutes = 15 , cache_dir = Path (self .temp_dir ))
2120
2221 def teardown_method (self ):
2322 """Clean up test fixtures."""
@@ -60,10 +59,9 @@ def test_stale_cache_retrieval(self):
6059
6160 def test_cache_minutes_parameter (self ):
6261 """Test that cache_expiry_minutes parameter works."""
63- with patch ('src.gitfetch.cache.CacheManager.CACHE_DIR' ,
64- Path (self .temp_dir )):
65- cache_manager = CacheManager (cache_expiry_minutes = 30 )
66- assert cache_manager .cache_expiry_minutes == 30
62+ cache_manager = CacheManager (
63+ cache_expiry_minutes = 30 , cache_dir = Path (self .temp_dir ))
64+ assert cache_manager .cache_expiry_minutes == 30
6765
6866 def test_cache_timestamp_update (self ):
6967 """Test that caching updates the timestamp."""
You can’t perform that action at this time.
0 commit comments