aboutsummaryrefslogtreecommitdiffhomepage
path: root/crates
diff options
context:
space:
mode:
authornsfisis <nsfisis@gmail.com>2026-06-21 04:14:43 +0900
committernsfisis <nsfisis@gmail.com>2026-06-21 04:14:43 +0900
commit9d6603239643075f5962d9496ecce9c7a8730c52 (patch)
tree57e3dab7ccbcc56e7f50d93295ea57b26af06cc2 /crates
parent343e6fcc129b47768059860e26ef6372170794b2 (diff)
downloadphp-shirabe-9d6603239643075f5962d9496ecce9c7a8730c52.tar.gz
php-shirabe-9d6603239643075f5962d9496ecce9c7a8730c52.tar.zst
php-shirabe-9d6603239643075f5962d9496ecce9c7a8730c52.zip
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) <noreply@anthropic.com>
Diffstat (limited to 'crates')
-rw-r--r--crates/shirabe/tests/cache_test.rs38
1 files changed, 38 insertions, 0 deletions
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<RefCell<dyn IOInterface>> = 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());
+}