use docbox_storage::UploadFileOptions;
use crate::common::minio::{test_minio_container, test_storage_factory};
mod common;
#[tokio::test]
async fn test_get_file_minio() {
let container = test_minio_container().await;
let storage_factory = test_storage_factory(&container).await;
let storage = storage_factory.create_test_layer();
storage.create_bucket().await.unwrap();
storage
.upload_file(
"test.txt",
"test".into(),
UploadFileOptions {
content_type: "text/plain".to_string(),
..Default::default()
},
)
.await
.unwrap();
let contents = storage
.get_file("test.txt")
.await
.unwrap()
.collect_bytes()
.await
.unwrap();
assert_eq!(contents.as_ref(), b"test");
}
#[tokio::test]
async fn test_get_unknown_file_minio() {
let container = test_minio_container().await;
let storage_factory = test_storage_factory(&container).await;
let storage = storage_factory.create_test_layer();
storage.create_bucket().await.unwrap();
storage.get_file("test.txt").await.unwrap_err();
}