From 47df073dbf6fbdedfc1a659d777272812b1142ae Mon Sep 17 00:00:00 2001 From: overtrue Date: Thu, 9 Apr 2026 06:04:35 +0800 Subject: [PATCH] test(cli): cover rm purge parser --- crates/cli/src/commands/mod.rs | 37 ++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/crates/cli/src/commands/mod.rs b/crates/cli/src/commands/mod.rs index 1c9532f..0abc8e3 100644 --- a/crates/cli/src/commands/mod.rs +++ b/crates/cli/src/commands/mod.rs @@ -472,4 +472,41 @@ mod tests { other => panic!("expected bucket command, got {:?}", other), } } + + #[test] + fn cli_accepts_rm_purge_flag() { + let cli = Cli::try_parse_from(["rc", "rm", "local/my-bucket/object.txt", "--purge"]) + .expect("parse rm purge"); + + match cli.command { + Commands::Rm(arg) => { + assert_eq!(arg.paths, vec!["local/my-bucket/object.txt"]); + assert!(arg.purge); + } + other => panic!("expected rm command, got {:?}", other), + } + } + + #[test] + fn cli_accepts_object_remove_purge_flag() { + let cli = Cli::try_parse_from([ + "rc", + "object", + "remove", + "local/my-bucket/object.txt", + "--purge", + ]) + .expect("parse object remove purge"); + + match cli.command { + Commands::Object(args) => match args.command { + object::ObjectCommands::Remove(arg) => { + assert_eq!(arg.paths, vec!["local/my-bucket/object.txt"]); + assert!(arg.purge); + } + other => panic!("expected object remove command, got {:?}", other), + }, + other => panic!("expected object command, got {:?}", other), + } + } }