Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ console = "0.16"
dirs = "6.0"
jiff = { version = "0.2", features = ["serde"] }
humansize = "2.1"
humantime = "2.3"
bytes = "1.11"
url = "2.5"
futures = "0.3"
Expand Down
1 change: 1 addition & 0 deletions crates/cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ console.workspace = true
# Utilities
jiff.workspace = true
humansize.workspace = true
humantime.workspace = true
mime_guess.workspace = true
glob.workspace = true
shlex.workspace = true
Expand Down
124 changes: 124 additions & 0 deletions crates/cli/src/commands/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -928,6 +928,33 @@ mod tests {
}
}

#[test]
fn cli_accepts_bucket_replication_diff_prefix() {
let cli = Cli::try_parse_from([
"rc",
"bucket",
"replication",
"diff",
"local/my-bucket",
"--prefix",
"reports/2026/",
])
.expect("parse bucket replication diff");

match cli.command {
Commands::Bucket(args) => match args.command {
bucket::BucketCommands::Replication(replicate::ReplicateArgs {
command: replicate::ReplicateCommands::Diff(arg),
}) => {
assert_eq!(arg.path, "local/my-bucket");
assert_eq!(arg.prefix.as_deref(), Some("reports/2026/"));
}
other => panic!("expected bucket replication diff command, got {:?}", other),
},
other => panic!("expected bucket command, got {:?}", other),
}
}

#[test]
fn cli_accepts_bucket_replication_add_tls_flags() {
let cli = Cli::try_parse_from([
Expand Down Expand Up @@ -957,6 +984,103 @@ mod tests {
}
}

#[test]
fn cli_accepts_bucket_replication_check_confirmation() {
let cli = Cli::try_parse_from([
"rc",
"bucket",
"replication",
"check",
"local/my-bucket",
"--yes",
"--force",
])
.expect("parse bucket replication check");

match cli.command {
Commands::Bucket(args) => match args.command {
bucket::BucketCommands::Replication(replicate::ReplicateArgs {
command: replicate::ReplicateCommands::Check(arg),
}) => {
assert_eq!(arg.path, "local/my-bucket");
assert!(arg.yes);
assert!(arg.force);
}
other => panic!("expected bucket replication check command, got {other:?}"),
},
other => panic!("expected bucket command, got {other:?}"),
}
}

#[test]
fn cli_accepts_bucket_replication_resync_lifecycle() {
let start = Cli::try_parse_from([
"rc",
"bucket",
"replication",
"resync",
"start",
"local/my-bucket",
"--target-arn",
"arn:rustfs:replication::id:backup",
"--older-than",
"7d",
"--reset-id",
"caller-id",
"--yes",
])
.expect("parse bucket replication resync start");

match start.command {
Commands::Bucket(args) => match args.command {
bucket::BucketCommands::Replication(replicate::ReplicateArgs {
command:
replicate::ReplicateCommands::Resync(replicate::ResyncCommands::Start(arg)),
}) => {
assert_eq!(arg.path, "local/my-bucket");
assert_eq!(
arg.target_arn.as_deref(),
Some("arn:rustfs:replication::id:backup")
);
assert_eq!(arg.older_than.as_deref(), Some("7d"));
assert_eq!(arg.reset_id.as_deref(), Some("caller-id"));
assert!(arg.yes);
}
other => panic!("expected bucket replication resync start, got {other:?}"),
},
other => panic!("expected bucket command, got {other:?}"),
}

let status = Cli::try_parse_from([
"rc",
"bucket",
"replication",
"resync",
"status",
"local/my-bucket",
"--target-arn",
"arn:rustfs:replication::id:backup",
])
.expect("parse bucket replication resync status");

match status.command {
Commands::Bucket(args) => match args.command {
bucket::BucketCommands::Replication(replicate::ReplicateArgs {
command:
replicate::ReplicateCommands::Resync(replicate::ResyncCommands::Status(arg)),
}) => {
assert_eq!(arg.path, "local/my-bucket");
assert_eq!(
arg.target_arn.as_deref(),
Some("arn:rustfs:replication::id:backup")
);
}
other => panic!("expected bucket replication resync status, got {other:?}"),
},
other => panic!("expected bucket command, got {other:?}"),
}
}

#[test]
fn cli_accepts_bucket_remove_subcommand() {
let cli = Cli::try_parse_from(["rc", "bucket", "remove", "local/my-bucket"])
Expand Down
Loading