Test updates.

This commit is contained in:
2026-09-29 22:35:03 +02:00
parent 3858dd7216
commit f7e3fc5342
5 changed files with 153 additions and 109 deletions
+19 -15
View File
@@ -42,6 +42,25 @@ mod tests {
}
}
#[test]
fn serializes_account_response() {
let id = Uuid::nil();
let account = request().into_domain(id).unwrap();
let response = serde_json::to_value(AccountResponse::from(account)).unwrap();
assert_eq!(response["id"], id.to_string());
assert_eq!(response["name"], "Savings");
}
#[test]
fn deserializes_account_response_as_request() {
let account = request().into_domain(Uuid::nil()).unwrap();
let response = serde_json::to_value(AccountResponse::from(account)).unwrap();
let request: AccountRequest = serde_json::from_value(response).unwrap();
assert_eq!(request.name, "Savings");
}
#[test]
fn converts_between_dto_and_domain() {
let id = Uuid::new_v4();
@@ -53,19 +72,4 @@ mod tests {
assert_eq!(response.id, id);
assert_eq!(response.name, "Savings");
}
#[test]
fn keeps_account_json_flat() {
let response = AccountResponse {
id: Uuid::nil(),
name: "Savings".to_owned(),
};
let response = serde_json::to_value(response).unwrap();
assert_eq!(response["id"], Uuid::nil().to_string());
assert_eq!(response["name"], "Savings");
let request: AccountRequest = serde_json::from_value(response).unwrap();
assert_eq!(request.name, "Savings");
}
}