test: move small adapter tests to tests/
event-publisher, export, rss, media-server, object-storage, nats(config).
Kept inline (private fn, no public path): nats src/subject.rs
tests::{review_logged_subject,review_updated_subject,movie_discovered_subject,
consumer_subject_filter_appends_wildcard} - event_to_subject/consumer_subject_filter private.
object-storage build_local_store tests rewritten via StorageConfig::from_config.
This commit is contained in:
@@ -62,7 +62,3 @@ fn build_local_store(path: &str) -> anyhow::Result<Arc<dyn ObjectStore>> {
|
||||
.context("Failed to initialise local file system store")?;
|
||||
Ok(Arc::new(store))
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
#[path = "tests/config.rs"]
|
||||
mod tests;
|
||||
|
||||
@@ -132,7 +132,3 @@ pub fn create(config: &::config::StorageConfig) -> anyhow::Result<Arc<dyn Object
|
||||
StorageConfig::from_config(config)?,
|
||||
)))
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
#[path = "tests/lib.rs"]
|
||||
mod tests;
|
||||
|
||||
@@ -1,4 +1,10 @@
|
||||
use super::*;
|
||||
use std::sync::Arc;
|
||||
|
||||
use domain::{
|
||||
errors::DomainError,
|
||||
ports::{EventHandler, ObjectStorage},
|
||||
};
|
||||
use object_storage::{ImageCleanupHandler, ObjectStorageAdapter};
|
||||
use object_store::memory::InMemory;
|
||||
|
||||
fn adapter() -> ObjectStorageAdapter {
|
||||
@@ -1,9 +1,17 @@
|
||||
use super::*;
|
||||
use object_storage::StorageConfig;
|
||||
|
||||
fn local_section(dir: &std::path::Path) -> config::StorageConfig {
|
||||
config::StorageConfig {
|
||||
backend: "local".into(),
|
||||
path: dir.to_str().unwrap().into(),
|
||||
..Default::default()
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn local_store_creates_dir_and_succeeds() {
|
||||
let dir = std::env::temp_dir().join(format!("image_test_{}", uuid::Uuid::new_v4()));
|
||||
let result = build_local_store(dir.to_str().unwrap());
|
||||
let result = StorageConfig::from_config(&local_section(&dir));
|
||||
assert!(result.is_ok(), "expected Ok, got: {:?}", result.err());
|
||||
assert!(dir.exists(), "directory should have been created");
|
||||
}
|
||||
@@ -12,13 +20,13 @@ fn local_store_creates_dir_and_succeeds() {
|
||||
fn local_store_succeeds_if_dir_already_exists() {
|
||||
let dir = std::env::temp_dir().join(format!("image_test_{}", uuid::Uuid::new_v4()));
|
||||
std::fs::create_dir_all(&dir).unwrap();
|
||||
let result = build_local_store(dir.to_str().unwrap());
|
||||
let result = StorageConfig::from_config(&local_section(&dir));
|
||||
assert!(result.is_ok());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn s3_backend_requires_endpoint() {
|
||||
let section = ::config::StorageConfig {
|
||||
let section = config::StorageConfig {
|
||||
backend: "s3".into(),
|
||||
..Default::default()
|
||||
};
|
||||
@@ -28,7 +36,7 @@ fn s3_backend_requires_endpoint() {
|
||||
|
||||
#[test]
|
||||
fn unknown_backend_is_error() {
|
||||
let section = ::config::StorageConfig {
|
||||
let section = config::StorageConfig {
|
||||
backend: "ftp".into(),
|
||||
..Default::default()
|
||||
};
|
||||
Reference in New Issue
Block a user