From b28546d2de1a41c308941843a67023a2397256fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Asger=20Juul=20Brunsh=C3=B8j?= Date: Wed, 19 Feb 2025 15:15:34 +0100 Subject: [PATCH] refactor: use test-try --- Cargo.lock | 21 +++++++++++++++++++++ crates/ascend/Cargo.toml | 3 +++ crates/ascend/src/codec.rs | 6 +++--- 3 files changed, 27 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 521cd03..85fd3e4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -173,6 +173,7 @@ dependencies = [ "serde_json", "server_fn", "smart-default", + "test-try", "tokio", "tower 0.4.13", "tower-http 0.5.2", @@ -3165,6 +3166,26 @@ version = "0.12.16" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "61c41af27dd6d1e27b1b16b489db798443478cef1f06a660c96db617ba5de3b1" +[[package]] +name = "test-try" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "072964fdfbf7d0f2bcc59b776e70a280a6a91de9d8a1768aa233a966b56d8538" +dependencies = [ + "test-try-macros", +] + +[[package]] +name = "test-try-macros" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "358ec8436371d72d3a2727a0c4f69493970e0c065d2810a6a65f0c5fd864acea" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "thiserror" version = "1.0.69" diff --git a/crates/ascend/Cargo.toml b/crates/ascend/Cargo.toml index a311d66..70dd1e8 100644 --- a/crates/ascend/Cargo.toml +++ b/crates/ascend/Cargo.toml @@ -54,6 +54,9 @@ getrandom = { version = "0.3.1" } [dev-dependencies.serde_json] version = "1" +[dev-dependencies.test-try] +version = "0.1" + [features] hydrate = ["leptos/hydrate", "getrandom/wasm_js", "uuid/js"] ssr = [ diff --git a/crates/ascend/src/codec.rs b/crates/ascend/src/codec.rs index 2d82e93..b8bfe9e 100644 --- a/crates/ascend/src/codec.rs +++ b/crates/ascend/src/codec.rs @@ -133,14 +133,14 @@ pub mod ron { value: i32, } - #[test] + #[test_try::test_try] fn test_ron_codec() { let original = TestStruct { name: "Test".to_string(), value: 42, }; - let enc = Ron::encode(&original).unwrap(); - let dec: TestStruct = Ron::decode(&enc).unwrap(); + let enc = Ron::encode(&original)?; + let dec: TestStruct = Ron::decode(&enc)?; assert_eq!(dec, original); } }