- Added AWS SDK S3 dependencies including aws-config, aws-sdk-s3, and related crates - Removed opendal dependency and replaced with AWS SDK S3 client - Implemented new get_file_content helper function using AWS SDK - Updated MinIOHandler to use AWS SDK client instead of opendal Operator - Modified file change detection to work with AWS SDK's S3 client The change was made to standardize on AWS's official SDK for S3 operations, which provides better maintenance and feature support compared to the opendal crate. This also aligns with AWS best practices for interacting with S3 services.
80 lines
2.3 KiB
Rust
80 lines
2.3 KiB
Rust
use super::*;
|
|
|
|
#[tokio::test]
|
|
async fn test_create_s3_client() {
|
|
if std::env::var("CI").is_ok() {
|
|
return; // Skip in CI environment
|
|
}
|
|
|
|
// Setup test environment variables
|
|
std::env::set_var("DRIVE_SERVER", "http://localhost:9000");
|
|
std::env::set_var("DRIVE_ACCESS_KEY", "minioadmin");
|
|
std::env::set_var("DRIVE_SECRET_KEY", "minioadmin");
|
|
|
|
match create_s3_client().await {
|
|
Ok(client) => {
|
|
// Verify client creation
|
|
assert!(client.config().region().is_some());
|
|
|
|
// Test bucket operations
|
|
if let Err(e) = create_bucket(&client, "test.gbai").await {
|
|
println!("Bucket creation failed: {:?}", e);
|
|
}
|
|
},
|
|
Err(e) => {
|
|
// Skip if no S3 server available
|
|
println!("S3 client creation failed: {:?}", e);
|
|
}
|
|
}
|
|
|
|
// Cleanup
|
|
std::env::remove_var("DRIVE_SERVER");
|
|
std::env::remove_var("DRIVE_ACCESS_KEY");
|
|
std::env::remove_var("DRIVE_SECRET_KEY");
|
|
}
|
|
|
|
#[tokio::test]
|
|
async fn test_bucket_exists() {
|
|
if std::env::var("CI").is_ok() {
|
|
return; // Skip in CI environment
|
|
}
|
|
|
|
// Setup test environment variables
|
|
std::env::set_var("DRIVE_SERVER", "http://localhost:9000");
|
|
std::env::set_var("DRIVE_ACCESS_KEY", "minioadmin");
|
|
std::env::set_var("DRIVE_SECRET_KEY", "minioadmin");
|
|
|
|
match create_s3_client().await {
|
|
Ok(client) => {
|
|
// Verify client creation
|
|
assert!(client.config().region().is_some());
|
|
},
|
|
Err(e) => {
|
|
// Skip if no S3 server available
|
|
println!("S3 client creation failed: {:?}", e);
|
|
}
|
|
}
|
|
}
|
|
|
|
#[tokio::test]
|
|
async fn test_create_bucket() {
|
|
if std::env::var("CI").is_ok() {
|
|
return; // Skip in CI environment
|
|
}
|
|
|
|
// Setup test environment variables
|
|
std::env::set_var("DRIVE_SERVER", "http://localhost:9000");
|
|
std::env::set_var("DRIVE_ACCESS_KEY", "minioadmin");
|
|
std::env::set_var("DRIVE_SECRET_KEY", "minioadmin");
|
|
|
|
match create_s3_client().await {
|
|
Ok(client) => {
|
|
// Verify client creation
|
|
assert!(client.config().region().is_some());
|
|
},
|
|
Err(e) => {
|
|
// Skip if no S3 server available
|
|
println!("S3 client creation failed: {:?}", e);
|
|
}
|
|
}
|
|
}
|