Repo layer refactor.
This commit is contained in:
@@ -59,9 +59,10 @@ where
|
||||
let transaction = db::upsert(executor, encode(transaction))
|
||||
.await
|
||||
.map_err(classify_upsert_error)?
|
||||
.try_map(decode)?;
|
||||
.try_map(decode)?
|
||||
.into();
|
||||
|
||||
Ok(transaction.into())
|
||||
Ok(transaction)
|
||||
}
|
||||
|
||||
fn classify_upsert_error(error: DatabaseError) -> RepositoryError {
|
||||
@@ -82,7 +83,9 @@ pub async fn delete_by_id<'e, E>(executor: E, id: Uuid) -> Result<Delete, Reposi
|
||||
where
|
||||
E: sqlx::Executor<'e, Database = sqlx::Postgres>,
|
||||
{
|
||||
Ok(db::delete_by_id(executor, id).await?.into())
|
||||
let result = db::delete_by_id(executor, id).await?.into();
|
||||
|
||||
Ok(result)
|
||||
}
|
||||
|
||||
fn decode(row: TransactionRow) -> Result<Transaction, DecodeError> {
|
||||
@@ -180,6 +183,7 @@ mod tests {
|
||||
#[test]
|
||||
fn round_trips_through_rows() {
|
||||
let transaction = decode(row()).unwrap();
|
||||
assert_eq!(decode(encode(transaction.clone())).unwrap(), transaction);
|
||||
let round_trip = decode(encode(transaction.clone())).unwrap();
|
||||
assert_eq!(round_trip, transaction);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user