refactor/tighten-architecture #26
@@ -84,7 +84,3 @@ pub fn create_event_channel(
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
#[path = "tests/lib.rs"]
|
||||
mod tests;
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
use super::*;
|
||||
use domain::ports::{EventConsumer, EventPublisher};
|
||||
use domain::{
|
||||
events::DomainEvent,
|
||||
value_objects::{ExternalMetadataId, MovieId},
|
||||
};
|
||||
use event_publisher::{EventPublisherConfig, create_event_channel};
|
||||
use futures::StreamExt;
|
||||
|
||||
fn movie_discovered() -> DomainEvent {
|
||||
@@ -107,7 +107,3 @@ fn entry_to_json(e: &DiaryEntry) -> serde_json::Value {
|
||||
"spoilers": e.review().spoilers(),
|
||||
})
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
#[path = "tests/lib.rs"]
|
||||
mod tests;
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
use super::ExportAdapter;
|
||||
use domain::{
|
||||
models::{DiaryEntry, ExportFormat, Movie, ReviewEdit},
|
||||
ports::DiaryExporter,
|
||||
@@ -7,6 +6,7 @@ use domain::{
|
||||
},
|
||||
value_objects::{Comment, ExternalMetadataId, UserId},
|
||||
};
|
||||
use export::ExportAdapter;
|
||||
|
||||
async fn collect_stream(
|
||||
stream: futures::stream::BoxStream<'static, Result<bytes::Bytes, domain::errors::DomainError>>,
|
||||
@@ -58,7 +58,3 @@ struct JellyfinPayload {
|
||||
#[serde(rename = "Provider_imdb")]
|
||||
provider_imdb: Option<String>,
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
#[path = "tests/jellyfin.rs"]
|
||||
mod tests;
|
||||
|
||||
@@ -68,7 +68,3 @@ struct PlexMetadata {
|
||||
struct PlexGuid {
|
||||
id: String,
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
#[path = "tests/plex.rs"]
|
||||
mod tests;
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
use super::*;
|
||||
use domain::ports::MediaServerParser;
|
||||
use media_server::JellyfinParser;
|
||||
|
||||
#[test]
|
||||
fn parses_valid_playback_stop() {
|
||||
@@ -1,4 +1,5 @@
|
||||
use super::*;
|
||||
use domain::ports::MediaServerParser;
|
||||
use media_server::PlexParser;
|
||||
|
||||
#[test]
|
||||
fn parses_movie_scrobble() {
|
||||
@@ -35,7 +35,3 @@ impl NatsConfig {
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
#[path = "tests/config.rs"]
|
||||
mod tests;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
use super::*;
|
||||
use nats::{NatsConfig, NatsMode};
|
||||
|
||||
fn section(url: Option<&str>, mode: &str) -> ::config::NatsConfig {
|
||||
::config::NatsConfig {
|
||||
fn section(url: Option<&str>, mode: &str) -> config::NatsConfig {
|
||||
config::NatsConfig {
|
||||
url: url.map(str::to_owned),
|
||||
mode: mode.into(),
|
||||
..Default::default()
|
||||
@@ -10,12 +10,12 @@ fn section(url: Option<&str>, mode: &str) -> ::config::NatsConfig {
|
||||
|
||||
#[test]
|
||||
fn errors_without_nats_url() {
|
||||
assert!(NatsConfig::from_config(&::config::NatsConfig::default()).is_err());
|
||||
assert!(NatsConfig::from_config(&config::NatsConfig::default()).is_err());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn defaults_with_only_url() {
|
||||
let cfg = NatsConfig::from_config(&::config::NatsConfig {
|
||||
let cfg = NatsConfig::from_config(&config::NatsConfig {
|
||||
url: Some("nats://localhost:4222".into()),
|
||||
..Default::default()
|
||||
})
|
||||
@@ -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()
|
||||
};
|
||||
@@ -88,7 +88,3 @@ impl RssFeedRenderer for RssAdapter {
|
||||
Ok(channel.to_string())
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
#[path = "tests/lib.rs"]
|
||||
mod tests;
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
use super::*;
|
||||
use domain::models::DiaryEntry;
|
||||
use domain::models::ReviewEdit;
|
||||
use domain::ports::{FeedChannel, RssFeedRenderer};
|
||||
use domain::testing::{test_movie_with_year, test_review};
|
||||
use domain::value_objects::{Comment, UserId};
|
||||
use rss::RssAdapter;
|
||||
|
||||
fn channel<'a>(title: &'a str) -> FeedChannel<'a> {
|
||||
FeedChannel {
|
||||
Reference in New Issue
Block a user