From bb01532e66df9e4e53a8f67c99b7eb63cc106461 Mon Sep 17 00:00:00 2001 From: overtrue Date: Tue, 14 Apr 2026 18:04:12 +0800 Subject: [PATCH] test(cors): cover empty normalized bucket path --- crates/cli/src/commands/cors.rs | 50 +++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/crates/cli/src/commands/cors.rs b/crates/cli/src/commands/cors.rs index 06dda15..1b22758 100644 --- a/crates/cli/src/commands/cors.rs +++ b/crates/cli/src/commands/cors.rs @@ -726,4 +726,54 @@ mod tests { assert!(cors_input_source(&args).is_err()); } + + #[tokio::test] + async fn test_execute_list_rejects_empty_normalized_bucket_path() { + let code = execute( + CorsArgs { + command: CorsCommands::List(BucketArg { + path: "local///".to_string(), + force: false, + }), + }, + OutputConfig::default(), + ) + .await; + + assert_eq!(code, ExitCode::UsageError); + } + + #[tokio::test] + async fn test_execute_set_rejects_empty_normalized_bucket_path_before_reading_source() { + let code = execute( + CorsArgs { + command: CorsCommands::Set(SetCorsArgs { + path: "local///".to_string(), + source: Some("missing-cors.json".to_string()), + file: None, + force: false, + }), + }, + OutputConfig::default(), + ) + .await; + + assert_eq!(code, ExitCode::UsageError); + } + + #[tokio::test] + async fn test_execute_remove_rejects_empty_normalized_bucket_path() { + let code = execute( + CorsArgs { + command: CorsCommands::Remove(BucketArg { + path: "local///".to_string(), + force: false, + }), + }, + OutputConfig::default(), + ) + .await; + + assert_eq!(code, ExitCode::UsageError); + } }