From 9d6603239643075f5962d9496ecce9c7a8730c52 Mon Sep 17 00:00:00 2001 From: nsfisis Date: Sun, 21 Jun 2026 04:14:43 +0900 Subject: test(cache): port CacheTest clearCache verified against a real Cache over a temp dir; the gc() cases mock Cache::getFinder (not overridable from a test) and are stubbed. setUp/tearDown not ported. Co-Authored-By: Claude Opus 4.8 (1M context) --- crates/shirabe/tests/cache_test.rs | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) (limited to 'crates') diff --git a/crates/shirabe/tests/cache_test.rs b/crates/shirabe/tests/cache_test.rs index c03f42b..3849705 100644 --- a/crates/shirabe/tests/cache_test.rs +++ b/crates/shirabe/tests/cache_test.rs @@ -1 +1,39 @@ //! ref: composer/tests/Composer/Test/CacheTest.php + +use std::cell::RefCell; +use std::rc::Rc; + +use shirabe::cache::Cache; +use shirabe::io::IOInterface; +use shirabe::io::null_io::NullIO; +use tempfile::TempDir; + +// In PHP these mock Cache::getFinder() to feed the gc() routine a controlled set of +// files. getFinder is pub(crate) and cannot be overridden from a test, so the +// finder-driven removal paths cannot be exercised faithfully here. +#[test] +#[ignore = "mocks Cache::getFinder to drive gc(); getFinder cannot be overridden from a test"] +fn test_remove_outdated_files() { + todo!() +} + +#[test] +#[ignore = "mocks Cache::getFinder to drive gc(); getFinder cannot be overridden from a test"] +fn test_remove_files_when_cache_is_too_large() { + todo!() +} + +#[test] +fn test_clear_cache() { + let root = TempDir::new().unwrap(); + let io: Rc> = Rc::new(RefCell::new(NullIO::new())); + let mut cache = Cache::new( + io, + root.path().to_str().unwrap(), + Some("a-z0-9."), + None, + false, + ); + + assert!(cache.clear()); +} -- cgit v1.3.1