1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
//! Defines the macro around mapping functions to traits for transactions.
)*
};
}
// #[cfg(test)]
// mod tests {
// use db_tx::db_transaction;
// use std::future::Future;
// struct TestStruct;
// trait TestTrait {
// fn test_fn() -> impl Future<Output = sqlx::Result<i32>> + Send;
// }
// #[db_transaction(TestStruct, TestTrait)]
// async fn test_fn() -> i32 {
// Ok(35)
// }
// #[tokio::test]
// async fn test_impl_transaction() {
// let outcome = TestStruct::test_fn().await;
// assert_eq!(outcome.unwrap(), 35);
// }
// #[tokio::test]
// async fn test_define_dal_transactions() {
// struct NewUser;
// define_dal_transactions!(
// CreateUser => create(user: NewUser) -> i32,
// DeleteUser => delete(id: i32) -> bool
// );
// struct PostgresHandle;
// #[db_transaction(PostgresHandle, DeleteUser)]
// async fn delete(_uid: i32) -> bool {
// Ok(true)
// }
// #[db_transaction(PostgresHandle, CreateUser)]
// async fn create(_user: NewUser) -> i32 {
// Ok(1)
// }
// let new_user = NewUser;
// let outcome = PostgresHandle::create(new_user).await.unwrap();
// assert_eq!(outcome, 1);
// let outcome = PostgresHandle::delete(1).await.unwrap();
// assert_eq!(outcome, true);
// }
// }