aboutsummaryrefslogtreecommitdiffhomepage
path: root/crates/shirabe/tests/package
diff options
context:
space:
mode:
authornsfisis <nsfisis@gmail.com>2026-08-02 17:32:43 +0900
committernsfisis <nsfisis@gmail.com>2026-08-02 17:32:43 +0900
commit7e31bab9ff7209c9b6d7928a581d7a449846f42e (patch)
treeb121966a169ee74afe04d066576e862a6702bbf6 /crates/shirabe/tests/package
parentebcb4a7f013c0511dd6617686395cef17822d1e2 (diff)
downloadphp-shirabe-7e31bab9ff7209c9b6d7928a581d7a449846f42e.tar.gz
php-shirabe-7e31bab9ff7209c9b6d7928a581d7a449846f42e.tar.zst
php-shirabe-7e31bab9ff7209c9b6d7928a581d7a449846f42e.zip
fix(json): propagate JsonFile::encode errors instead of unwrapping
PHP's JsonFile::encode throws a RuntimeException when json_encode fails; the port swallowed that into an .unwrap() marked TODO(phase-c). Return anyhow::Result from encode/encode_with_options and propagate at every call site (print_table and list_repositories become Result-returning to carry it). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Diffstat (limited to 'crates/shirabe/tests/package')
-rw-r--r--crates/shirabe/tests/package/locker_test.rs7
1 files changed, 4 insertions, 3 deletions
diff --git a/crates/shirabe/tests/package/locker_test.rs b/crates/shirabe/tests/package/locker_test.rs
index c355c774..f1747166 100644
--- a/crates/shirabe/tests/package/locker_test.rs
+++ b/crates/shirabe/tests/package/locker_test.rs
@@ -17,7 +17,7 @@ fn null_io() -> std::rc::Rc<std::cell::RefCell<dyn IOInterface>> {
std::rc::Rc::new(std::cell::RefCell::new(NullIO::new()))
}
-/// ref: LockerTest::getJsonContent — `JsonFile::encode(ksort([minimum-stability, name]), 0)`.
+/// ref: LockerTest::getJsonContent — `JsonFile::encode(ksort([minimum-stability, name]), 0).unwrap()`.
fn get_json_content(custom_data: &[(&str, &str)]) -> String {
let mut data: IndexMap<String, PhpMixed> = IndexMap::new();
data.insert(
@@ -30,7 +30,7 @@ fn get_json_content(custom_data: &[(&str, &str)]) -> String {
}
data.sort_keys();
- JsonFile::encode_with_options(&PhpMixed::Array(data), JsonEncodeOptions::none())
+ JsonFile::encode_with_options(&PhpMixed::Array(data), JsonEncodeOptions::none()).unwrap()
}
/// Builds a `Locker` backed by a real `composer.lock` `JsonFile` inside a fresh temp dir,
@@ -246,7 +246,8 @@ fn test_is_fresh_false() {
m
}),
JsonEncodeOptions::none(),
- );
+ )
+ .unwrap();
let (mut locker, _temp_dir, _io) = make_locker(&json_content, Some(&lock));
assert!(!locker.is_fresh().unwrap());