test: shared factories and command builders
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
use crate::test_support::request_wrap_up_command;
|
||||
use chrono::NaiveDate;
|
||||
use domain::events::DomainEvent;
|
||||
use domain::models::wrapup::{WrapUpRecord, WrapUpStatus};
|
||||
@@ -21,11 +22,7 @@ fn deps(
|
||||
}
|
||||
|
||||
fn past_cmd() -> RequestWrapUpCommand {
|
||||
RequestWrapUpCommand {
|
||||
user_id: Some(Uuid::nil()),
|
||||
start_date: NaiveDate::from_ymd_opt(2024, 1, 1).unwrap(),
|
||||
end_date: NaiveDate::from_ymd_opt(2025, 1, 1).unwrap(),
|
||||
}
|
||||
request_wrap_up_command(Some(Uuid::nil()), 2024)
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
@@ -105,16 +102,9 @@ async fn replaces_failed_wrapup() {
|
||||
async fn rejects_future_end_date() {
|
||||
let repo = InMemoryWrapUpRepository::new();
|
||||
let events = NoopEventPublisher::new();
|
||||
let err = generate::execute(
|
||||
&deps(&repo, &events),
|
||||
RequestWrapUpCommand {
|
||||
user_id: None,
|
||||
start_date: NaiveDate::from_ymd_opt(2030, 1, 1).unwrap(),
|
||||
end_date: NaiveDate::from_ymd_opt(2031, 1, 1).unwrap(),
|
||||
},
|
||||
)
|
||||
.await
|
||||
.unwrap_err();
|
||||
let err = generate::execute(&deps(&repo, &events), request_wrap_up_command(None, 2030))
|
||||
.await
|
||||
.unwrap_err();
|
||||
|
||||
assert!(err.to_string().contains("future"));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user