Files
movies-diary/crates/application/src/integrations/tests/generate_token.rs
Gabriel Kaszewski d867a14b28
Some checks failed
CI / Check / Test (push) Has been cancelled
add 400+ unit tests for domain and application layers
Extract ReviewLogger trait to decouple import/integrations
from diary::log_review (cross-module coupling smell).

Add in-memory fakes for all repository ports, enabling
isolated testing of every use case module without a database.

Coverage: domain+application 22% → 80%, 427 tests.
2026-06-09 02:07:26 +02:00

40 lines
1.0 KiB
Rust

use std::sync::Arc;
use domain::models::WatchEventSource;
use domain::testing::InMemoryWebhookTokenRepository;
use uuid::Uuid;
use crate::integrations::{commands::GenerateWebhookTokenCommand, generate_token};
use crate::test_helpers::TestContextBuilder;
#[tokio::test]
async fn generates_token_and_saves() {
let tokens = InMemoryWebhookTokenRepository::new();
let ctx = TestContextBuilder::new()
.with_webhook_tokens(Arc::clone(&tokens) as _)
.build();
let user_id = Uuid::new_v4();
let result = generate_token::execute(
&ctx,
GenerateWebhookTokenCommand {
user_id,
provider: WatchEventSource::Jellyfin,
label: None,
},
)
.await
.unwrap();
assert!(!result.token_plaintext.is_empty());
let saved = ctx
.repos
.webhook_token
.list_by_user(&domain::value_objects::UserId::from_uuid(user_id))
.await
.unwrap();
assert_eq!(saved.len(), 1);
assert_eq!(saved[0].id().value(), result.token.id().value());
}