aboutsummaryrefslogtreecommitdiffhomepage
path: root/crates/shirabe/tests
diff options
context:
space:
mode:
Diffstat (limited to 'crates/shirabe/tests')
-rw-r--r--crates/shirabe/tests/command/bump_command_test.rs3
-rw-r--r--crates/shirabe/tests/command/remove_command_test.rs2
-rw-r--r--crates/shirabe/tests/command/repository_command_test.rs2
-rw-r--r--crates/shirabe/tests/command/require_command_test.rs3
-rw-r--r--crates/shirabe/tests/installer_test.rs6
-rw-r--r--crates/shirabe/tests/json/json_file_test.rs8
-rw-r--r--crates/shirabe/tests/json/json_manipulator_test.rs2
-rw-r--r--crates/shirabe/tests/package/locker_test.rs7
-rw-r--r--crates/shirabe/tests/repository/composer_repository_test.rs2
-rw-r--r--crates/shirabe/tests/repository/vcs/forgejo_driver_test.rs7
-rw-r--r--crates/shirabe/tests/repository/vcs/gitlab_driver_test.rs2
-rw-r--r--crates/shirabe/tests/repository/vcs_repository_test.rs6
12 files changed, 29 insertions, 21 deletions
diff --git a/crates/shirabe/tests/command/bump_command_test.rs b/crates/shirabe/tests/command/bump_command_test.rs
index 509b42a7..d511f2a1 100644
--- a/crates/shirabe/tests/command/bump_command_test.rs
+++ b/crates/shirabe/tests/command/bump_command_test.rs
@@ -43,7 +43,8 @@ fn run_bump_case(
let mut json = JsonFile::new("./composer.json".to_string(), None, None).unwrap();
let read = json.read().unwrap();
- let actual: serde_json::Value = serde_json::from_str(&JsonFile::encode(&read)).unwrap();
+ let actual: serde_json::Value =
+ serde_json::from_str(&JsonFile::encode(&read).unwrap()).unwrap();
assert_eq!(expected, actual);
drop(tear_down);
diff --git a/crates/shirabe/tests/command/remove_command_test.rs b/crates/shirabe/tests/command/remove_command_test.rs
index 52e27829..7b195746 100644
--- a/crates/shirabe/tests/command/remove_command_test.rs
+++ b/crates/shirabe/tests/command/remove_command_test.rs
@@ -28,7 +28,7 @@ fn input(pairs: Vec<(&str, PhpMixed)>) -> Vec<(PhpMixed, PhpMixed)> {
fn read_json_file(path: &str) -> serde_json::Value {
let mut json = JsonFile::new(path.to_string(), None, None).unwrap();
let read = json.read().unwrap();
- serde_json::from_str(&JsonFile::encode(&read)).unwrap()
+ serde_json::from_str(&JsonFile::encode(&read).unwrap()).unwrap()
}
/// Mirrors PHPUnit's assertEmpty for a decoded JSON document (empty object/array/null).
diff --git a/crates/shirabe/tests/command/repository_command_test.rs b/crates/shirabe/tests/command/repository_command_test.rs
index 901b9f3e..48ca301a 100644
--- a/crates/shirabe/tests/command/repository_command_test.rs
+++ b/crates/shirabe/tests/command/repository_command_test.rs
@@ -9,7 +9,7 @@ use shirabe_php_shim::PhpMixed;
fn read_composer_json() -> serde_json::Value {
let mut json = JsonFile::new("./composer.json".to_string(), None, None).unwrap();
let read = json.read().unwrap();
- serde_json::from_str(&JsonFile::encode(&read)).unwrap()
+ serde_json::from_str(&JsonFile::encode(&read).unwrap()).unwrap()
}
#[test]
diff --git a/crates/shirabe/tests/command/require_command_test.rs b/crates/shirabe/tests/command/require_command_test.rs
index f23a6951..4237c4f8 100644
--- a/crates/shirabe/tests/command/require_command_test.rs
+++ b/crates/shirabe/tests/command/require_command_test.rs
@@ -385,7 +385,8 @@ fn test_inconsistent_require_keys() {
let mut composer_content =
JsonFile::new(format!("{}/composer.json", dir.display()), None, None).unwrap();
let content = composer_content.read().unwrap();
- let content: serde_json::Value = serde_json::from_str(&JsonFile::encode(&content)).unwrap();
+ let content: serde_json::Value =
+ serde_json::from_str(&JsonFile::encode(&content).unwrap()).unwrap();
assert!(
content.get(other_key).is_some(),
"expected key {other_key} present"
diff --git a/crates/shirabe/tests/installer_test.rs b/crates/shirabe/tests/installer_test.rs
index b81ec7a4..d0b60ba8 100644
--- a/crates/shirabe/tests/installer_test.rs
+++ b/crates/shirabe/tests/installer_test.rs
@@ -707,7 +707,8 @@ fn load_integration_tests(path: &str) -> Vec<IntegrationCase> {
let encoded = JsonFile::encode_with_options(
&composer,
shirabe::json::JsonEncodeOptions::none(),
- );
+ )
+ .unwrap();
let hash = format!("{:x}", md5::compute(encoded.as_bytes()));
lock["hash"] = serde_json::Value::String(hash);
}
@@ -926,7 +927,8 @@ fn do_test_integration(case: &IntegrationCase, expect_output: Option<&str>) {
// escaped), or the freshness check spuriously fails on any composer.json containing "/"
// (e.g. any vendor/package name).
let contents =
- JsonFile::encode_with_options(&case.composer, shirabe::json::JsonEncodeOptions::none());
+ JsonFile::encode_with_options(&case.composer, shirabe::json::JsonEncodeOptions::none())
+ .unwrap();
let locker = Locker::new(io.clone(), lock_json, locker_im, &contents, process);
composer
.borrow_mut()
diff --git a/crates/shirabe/tests/json/json_file_test.rs b/crates/shirabe/tests/json/json_file_test.rs
index 195c6918..7aac35a9 100644
--- a/crates/shirabe/tests/json/json_file_test.rs
+++ b/crates/shirabe/tests/json/json_file_test.rs
@@ -16,8 +16,8 @@ fn expect_parse_exception(text: &str, json: &str) {
fn assert_json_format(json: &str, data: &PhpMixed, options: Option<JsonEncodeOptions>) {
let json = json.replace('\r', "");
match options {
- None => assert_eq!(json, JsonFile::encode(data)),
- Some(options) => assert_eq!(json, JsonFile::encode_with_options(data, options)),
+ None => assert_eq!(json, JsonFile::encode(data).unwrap()),
+ Some(options) => assert_eq!(json, JsonFile::encode_with_options(data, options).unwrap()),
}
}
@@ -191,11 +191,11 @@ fn test_double_escaped_unicode() {
PhpMixed::String("Zdjęcia".to_string()),
PhpMixed::String("hjkjhl\\u0119kkjk".to_string()),
]);
- let encoded_data = JsonFile::encode(&data);
+ let encoded_data = JsonFile::encode(&data).unwrap();
let mut wrapper: IndexMap<String, PhpMixed> = IndexMap::new();
wrapper.insert("t".to_string(), PhpMixed::String(encoded_data));
- let double_encoded_data = JsonFile::encode(&PhpMixed::Array(wrapper));
+ let double_encoded_data = JsonFile::encode(&PhpMixed::Array(wrapper)).unwrap();
let decoded_data = shirabe_php_shim::json_decode(&double_encoded_data, true).unwrap();
let t = decoded_data.as_array().unwrap().get("t").unwrap();
diff --git a/crates/shirabe/tests/json/json_manipulator_test.rs b/crates/shirabe/tests/json/json_manipulator_test.rs
index 00fa7c24..8e418e2d 100644
--- a/crates/shirabe/tests/json/json_manipulator_test.rs
+++ b/crates/shirabe/tests/json/json_manipulator_test.rs
@@ -4128,7 +4128,7 @@ fn test_remove_main_key_removes_key_where_value_is_null() {
manipulator.remove_main_key("bar").unwrap();
- let expected = JsonFile::encode(&arr(&[("foo", PhpMixed::Int(9000))]));
+ let expected = JsonFile::encode(&arr(&[("foo", PhpMixed::Int(9000))])).unwrap();
assert_eq!(
JsonFile::parse_json(Some(&expected), None).unwrap(),
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());
diff --git a/crates/shirabe/tests/repository/composer_repository_test.rs b/crates/shirabe/tests/repository/composer_repository_test.rs
index 0d1439b5..1670cb79 100644
--- a/crates/shirabe/tests/repository/composer_repository_test.rs
+++ b/crates/shirabe/tests/repository/composer_repository_test.rs
@@ -62,7 +62,7 @@ fn repo_config(url: &str) -> IndexMap<String, PhpMixed> {
}
fn json_encode(value: &PhpMixed) -> String {
- shirabe::json::json_file::JsonFile::encode(value)
+ shirabe::json::json_file::JsonFile::encode(value).unwrap()
}
fn str_kv(pairs: &[(&str, PhpMixed)]) -> PhpMixed {
diff --git a/crates/shirabe/tests/repository/vcs/forgejo_driver_test.rs b/crates/shirabe/tests/repository/vcs/forgejo_driver_test.rs
index d9138b0c..46d3832d 100644
--- a/crates/shirabe/tests/repository/vcs/forgejo_driver_test.rs
+++ b/crates/shirabe/tests/repository/vcs/forgejo_driver_test.rs
@@ -123,6 +123,7 @@ fn repo_body() -> String {
);
m
}))
+ .unwrap()
}
#[test]
@@ -175,7 +176,8 @@ fn test_get_branches() {
entry.insert("name".to_string(), PhpMixed::String("main".to_string()));
entry.insert("commit".to_string(), PhpMixed::Array(commit));
entry
- })]));
+ })]))
+ .unwrap();
let (http_downloader, _http_guard) = http_mock(vec![
expect_full(
@@ -217,7 +219,8 @@ fn test_get_tags() {
entry.insert("name".to_string(), PhpMixed::String("1.0".to_string()));
entry.insert("commit".to_string(), PhpMixed::Array(commit));
entry
- })]));
+ })]))
+ .unwrap();
let (http_downloader, _http_guard) = http_mock(vec![
expect_full(
diff --git a/crates/shirabe/tests/repository/vcs/gitlab_driver_test.rs b/crates/shirabe/tests/repository/vcs/gitlab_driver_test.rs
index 2dd968ce..aa89040d 100644
--- a/crates/shirabe/tests/repository/vcs/gitlab_driver_test.rs
+++ b/crates/shirabe/tests/repository/vcs/gitlab_driver_test.rs
@@ -513,7 +513,7 @@ fn test_get_paginated_refs() {
"2013-03-09T16:35:23.000+01:00",
));
}
- let branch_data = shirabe::json::JsonFile::encode(&PhpMixed::List(branch_data));
+ let branch_data = shirabe::json::JsonFile::encode(&PhpMixed::List(branch_data)).unwrap();
let (http_downloader, _guard) = get_http_downloader_mock(
vec![
diff --git a/crates/shirabe/tests/repository/vcs_repository_test.rs b/crates/shirabe/tests/repository/vcs_repository_test.rs
index 9ae3eac4..79d40a5d 100644
--- a/crates/shirabe/tests/repository/vcs_repository_test.rs
+++ b/crates/shirabe/tests/repository/vcs_repository_test.rs
@@ -60,7 +60,7 @@ fn set_up() -> Option<SetUp> {
// add composed tag & master branch
write_file(
"composer.json",
- &shirabe::json::JsonFile::encode(&composer(None)),
+ &shirabe::json::JsonFile::encode(&composer(None)).unwrap(),
);
exec(&["add", "composer.json"]);
exec(&["commit", "-m", "addcomposer"]);
@@ -79,7 +79,7 @@ fn set_up() -> Option<SetUp> {
exec(&["checkout", "master"]);
write_file(
"composer.json",
- &shirabe::json::JsonFile::encode(&composer(Some("1.0.0"))),
+ &shirabe::json::JsonFile::encode(&composer(Some("1.0.0"))).unwrap(),
);
exec(&["add", "composer.json"]);
exec(&["commit", "-m", "addversion"]);
@@ -105,7 +105,7 @@ fn set_up() -> Option<SetUp> {
// update master to 2.0
write_file(
"composer.json",
- &shirabe::json::JsonFile::encode(&composer(Some("2.0.0"))),
+ &shirabe::json::JsonFile::encode(&composer(Some("2.0.0"))).unwrap(),
);
exec(&["add", "composer.json"]);
exec(&["commit", "-m", "bump-version"]);