From b8225cbc04d52c6fff9fd979a4dd63dcc77865f3 Mon Sep 17 00:00:00 2001 From: Robert Garrett Date: Wed, 4 Jun 2025 11:41:24 -0500 Subject: [PATCH] Test should-panic when uploading missing file I'm not sure I want this code path to panic, actually... It should probably return some error result so the app can print an error diagonstic. Oh well. That's a future problem. The end result is functionally identical. --- src/api/release_attachment.rs | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/src/api/release_attachment.rs b/src/api/release_attachment.rs index 1cc5884..028cc9c 100644 --- a/src/api/release_attachment.rs +++ b/src/api/release_attachment.rs @@ -73,9 +73,30 @@ mod tests { .await; } - #[test] - fn attach_file_missing() { - todo!(); + #[tokio::test] + #[should_panic] + async fn attach_file_missing() { + let conf = TestConfig::new(); + let release_candidates = + crate::api::release::list_releases( + &conf.client, + &conf.server, + &conf.repo + ) + .await + .expect("Failed to get releases. Pre-conditions unmet, aborting test!"); + + let release = match_release_by_tag(&conf.release_tag, release_candidates) + .expect("Failed to select matching release. Pre-conditions unmet, aborting test!"); + + let api_result = super::create_release_attachment( + &conf.client, + &conf.server, + &conf.repo, + release.id, + vec![String::from("./this-file-doesnt-exist")], + ) + .await; } struct TestConfig {