From 6268a1a6fde0980ea5eb86c689a89d2c41aab6d4 Mon Sep 17 00:00:00 2001 From: David Sherret Date: Tue, 22 Mar 2022 15:10:00 -0400 Subject: chore: replace `.expect("...")` calls with `.unwrap()` in test code (#14081) --- cli/tests/integration/fmt_tests.rs | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) (limited to 'cli/tests/integration/fmt_tests.rs') diff --git a/cli/tests/integration/fmt_tests.rs b/cli/tests/integration/fmt_tests.rs index bb4c8b451..aa807b727 100644 --- a/cli/tests/integration/fmt_tests.rs +++ b/cli/tests/integration/fmt_tests.rs @@ -6,30 +6,27 @@ use test_util as util; #[test] fn fmt_test() { - let t = TempDir::new().expect("tempdir fail"); + let t = TempDir::new().unwrap(); let fixed_js = util::testdata_path().join("badly_formatted_fixed.js"); let badly_formatted_original_js = util::testdata_path().join("badly_formatted.mjs"); let badly_formatted_js = t.path().join("badly_formatted.js"); let badly_formatted_js_str = badly_formatted_js.to_str().unwrap(); - std::fs::copy(&badly_formatted_original_js, &badly_formatted_js) - .expect("Failed to copy file"); + std::fs::copy(&badly_formatted_original_js, &badly_formatted_js).unwrap(); let fixed_md = util::testdata_path().join("badly_formatted_fixed.md"); let badly_formatted_original_md = util::testdata_path().join("badly_formatted.md"); let badly_formatted_md = t.path().join("badly_formatted.md"); let badly_formatted_md_str = badly_formatted_md.to_str().unwrap(); - std::fs::copy(&badly_formatted_original_md, &badly_formatted_md) - .expect("Failed to copy file"); + std::fs::copy(&badly_formatted_original_md, &badly_formatted_md).unwrap(); let fixed_json = util::testdata_path().join("badly_formatted_fixed.json"); let badly_formatted_original_json = util::testdata_path().join("badly_formatted.json"); let badly_formatted_json = t.path().join("badly_formatted.json"); let badly_formatted_json_str = badly_formatted_json.to_str().unwrap(); - std::fs::copy(&badly_formatted_original_json, &badly_formatted_json) - .expect("Failed to copy file"); + std::fs::copy(&badly_formatted_original_json, &badly_formatted_json).unwrap(); // First, check formatting by ignoring the badly formatted file. let status = util::deno_cmd() .current_dir(util::testdata_path()) @@ -43,9 +40,9 @@ fn fmt_test() { .arg(badly_formatted_md_str) .arg(badly_formatted_json_str) .spawn() - .expect("Failed to spawn script") + .unwrap() .wait() - .expect("Failed to wait for child process"); + .unwrap(); // No target files found assert!(!status.success()); @@ -58,9 +55,9 @@ fn fmt_test() { .arg(badly_formatted_md_str) .arg(badly_formatted_json_str) .spawn() - .expect("Failed to spawn script") + .unwrap() .wait() - .expect("Failed to wait for child process"); + .unwrap(); assert!(!status.success()); // Format the source file. @@ -71,9 +68,9 @@ fn fmt_test() { .arg(badly_formatted_md_str) .arg(badly_formatted_json_str) .spawn() - .expect("Failed to spawn script") + .unwrap() .wait() - .expect("Failed to wait for child process"); + .unwrap(); assert!(status.success()); let expected_js = std::fs::read_to_string(fixed_js).unwrap(); let expected_md = std::fs::read_to_string(fixed_md).unwrap(); -- cgit v1.2.3