#[cfg(feature = "remote")]
mod remote_auth_tests {
use blazehash::remote::operator::operator_for_uri;
#[test]
fn test_mem_backend_round_trip() {
use opendal::{blocking, services, Operator};
let rt = tokio::runtime::Builder::new_current_thread()
.enable_all()
.build()
.unwrap();
let _guard = rt.enter();
let async_op = Operator::new(services::Memory::default())
.unwrap()
.finish();
let op = blocking::Operator::new(async_op).unwrap();
op.write("test/data.bin", b"round trip content".to_vec()).unwrap();
let result = op.read("test/data.bin").unwrap();
assert_eq!(result.to_vec(), b"round trip content");
}
#[test]
fn test_operator_for_uri_mem_succeeds() {
let result = operator_for_uri("mem://testbucket/key.hash");
assert!(result.is_ok(), "mem:// should build successfully: {:?}", result.err());
}
#[test]
fn test_operator_for_uri_unknown_scheme_fails() {
let result = operator_for_uri("ftp://host/file");
assert!(result.is_err());
let msg = result.unwrap_err().to_string();
assert!(msg.contains("unsupported") || msg.contains("ftp"), "error: {msg}");
}
#[test]
fn test_operator_for_uri_s3_builds_without_credentials() {
std::env::set_var("AWS_DEFAULT_REGION", "us-east-1");
let result = operator_for_uri("s3://test-bucket/key");
let _ = result; }
}
#[test]
fn test_remote_config_flag_cli() {
use assert_cmd::Command;
let output = Command::cargo_bin("blazehash")
.unwrap()
.args(["--remote-config", "region=eu-west-1", "--help"])
.output()
.unwrap();
let stdout = String::from_utf8_lossy(&output.stdout);
let stderr = String::from_utf8_lossy(&output.stderr);
let combined = format!("{stdout}{stderr}");
assert!(
combined.contains("remote-config") || combined.contains("unexpected argument"),
"output: {combined}"
);
}