test_support/test_helpers -> tests/support; watched_at unified w/ domain test_watched_at (2024-03-15). Kept inline: users::diary_filter tests (feed_sort_to_direction_all_variants, paged_user_filter_builds_correctly) - pub(super) helpers in private module. Dropped stale never-compiled users/tests/get_users.rs (old execute signature).
44 lines
1.3 KiB
Rust
44 lines
1.3 KiB
Rust
use chrono::NaiveDate;
|
|
use domain::models::wrapup::{WrapUpRecord, WrapUpStatus};
|
|
use domain::testing::InMemoryWrapUpRepository;
|
|
use domain::value_objects::WrapUpId;
|
|
|
|
use application::wrapup::deps::GetWrapUpDeps;
|
|
use application::wrapup::get_wrapup;
|
|
|
|
#[tokio::test]
|
|
async fn returns_record_when_exists() {
|
|
let repo = InMemoryWrapUpRepository::new();
|
|
let id = WrapUpId::generate();
|
|
repo.store.lock().unwrap().push(WrapUpRecord {
|
|
id: id.clone(),
|
|
user_id: None,
|
|
start_date: NaiveDate::from_ymd_opt(2024, 1, 1).unwrap(),
|
|
end_date: NaiveDate::from_ymd_opt(2025, 1, 1).unwrap(),
|
|
status: WrapUpStatus::Pending,
|
|
report: None,
|
|
error_message: None,
|
|
created_at: chrono::Utc::now().naive_utc(),
|
|
completed_at: None,
|
|
});
|
|
|
|
let deps = GetWrapUpDeps {
|
|
wrapup_repo: repo.clone(),
|
|
};
|
|
let result = get_wrapup::execute(&deps, id).await.unwrap();
|
|
assert!(result.is_some());
|
|
assert_eq!(result.unwrap().status, WrapUpStatus::Pending);
|
|
}
|
|
|
|
#[tokio::test]
|
|
async fn returns_none_when_missing() {
|
|
let repo = InMemoryWrapUpRepository::new();
|
|
let deps = GetWrapUpDeps {
|
|
wrapup_repo: repo.clone(),
|
|
};
|
|
let result = get_wrapup::execute(&deps, WrapUpId::generate())
|
|
.await
|
|
.unwrap();
|
|
assert!(result.is_none());
|
|
}
|