#[cfg(test)]
mod tests {
use crate::config::args::*;
#[test]
fn with_default_value() {
init_dummy_tracing_subscriber();
let args = vec![
"s3sync",
"--source-profile",
"source_profile",
"--target-profile",
"target_profile",
"s3://source-bucket/source_key",
"s3://target-bucket/target_key",
];
let config = build_config_from_args(args).unwrap();
assert!(config.filter_config.check_checksum_algorithm.is_none());
}
#[test]
fn with_custom_value() {
init_dummy_tracing_subscriber();
let args = vec![
"s3sync",
"--source-profile",
"source_profile",
"--target-profile",
"target_profile",
"--check-additional-checksum",
"SHA256",
"s3://source-bucket/source_key",
"s3://target-bucket/target_key",
];
let config = build_config_from_args(args).unwrap();
assert_eq!(
config
.filter_config
.check_checksum_algorithm
.unwrap()
.to_string(),
"SHA256"
);
}
#[test]
fn with_custom_value_with_conflict_check_size() {
init_dummy_tracing_subscriber();
let args = vec![
"s3sync",
"--source-profile",
"source_profile",
"--target-profile",
"target_profile",
"--check-size",
"--check-additional-checksum",
"SHA256",
"s3://source-bucket/source_key",
"s3://target-bucket/target_key",
];
let config = build_config_from_args(args);
assert!(config.is_err());
}
#[test]
fn with_custom_value_with_conflict_check_e_tag() {
init_dummy_tracing_subscriber();
let args = vec![
"s3sync",
"--source-profile",
"source_profile",
"--target-profile",
"target_profile",
"--check-etag",
"--check-additional-checksum",
"SHA256",
"s3://source-bucket/source_key",
"s3://target-bucket/target_key",
];
let config = build_config_from_args(args);
assert!(config.is_err());
}
#[test]
fn with_custom_value_with_conflict_versioning() {
init_dummy_tracing_subscriber();
let args = vec![
"s3sync",
"--source-profile",
"source_profile",
"--target-profile",
"target_profile",
"--enable-versioning",
"--check-additional-checksum",
"SHA256",
"s3://source-bucket/source_key",
"s3://target-bucket/target_key",
];
let config = build_config_from_args(args);
assert!(config.is_err());
}
fn init_dummy_tracing_subscriber() {
let _ = tracing_subscriber::fmt()
.with_env_filter("dummy=trace")
.try_init();
}
}