Skip to content

Commit 9a6168c

Browse files
author
Vincent Rouillé
committed
Add tests for boot_async
1 parent a5eee48 commit 9a6168c

File tree

1 file changed

+53
-0
lines changed

1 file changed

+53
-0
lines changed

foundationdb/tests/tokio_async.rs

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
use foundationdb::*;
2+
use futures::prelude::*;
3+
use std::sync::Arc;
4+
5+
mod common;
6+
7+
#[tokio::test]
8+
async fn test_tokio_send() {
9+
boot_async(|| async {
10+
do_transact().await;
11+
do_trx().await;
12+
}).await
13+
}
14+
15+
async fn do_transact() {
16+
let db = Arc::new(
17+
foundationdb::Database::new_compat(None)
18+
.await
19+
.expect("failed to open fdb"),
20+
);
21+
22+
let adb = db.clone();
23+
tokio::spawn(async move {
24+
async fn txnfn(_txn: &Transaction) -> FdbResult<()> {
25+
Ok(())
26+
}
27+
28+
adb.transact_boxed(
29+
(),
30+
|txn: &Transaction, ()| txnfn(txn).boxed(),
31+
TransactOption::default(),
32+
)
33+
.await
34+
.expect("failed to transact")
35+
});
36+
}
37+
38+
async fn do_trx() {
39+
let db = Arc::new(
40+
foundationdb::Database::new_compat(None)
41+
.await
42+
.expect("failed to open fdb"),
43+
);
44+
45+
let adb = db.clone();
46+
tokio::spawn(async move {
47+
adb.create_trx()
48+
.expect("failed to create trx")
49+
.commit()
50+
.await
51+
.expect("failed to commit");
52+
});
53+
}

0 commit comments

Comments
 (0)