Skip to content

Commit 55bf7a3

Browse files
committed
init_sync change according to pr comment, cargo fmt
Signed-off-by: Otto Westerlund <westerlundotto@gmail.com>
1 parent 63c94d1 commit 55bf7a3

2 files changed

Lines changed: 16 additions & 12 deletions

File tree

tests/common/mod.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,11 @@ pub async fn init() -> Result<()> {
7575
}
7676

7777
pub fn init_sync() -> Result<()> {
78-
tokio::runtime::Runtime::new()?.block_on(init())
78+
if let Ok(handle) = tokio::runtime::Handle::try_current() {
79+
handle.block_on(init())
80+
} else {
81+
tokio::runtime::Runtime::new()?.block_on(init())
82+
}
7983
}
8084

8185
async fn ensure_region_split(

tests/sync_transaction_tests.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -271,11 +271,11 @@ fn sync_txn_scan() -> Result<()> {
271271
let results: Vec<_> = txn
272272
.scan("key1".to_owned().."key4".to_owned(), 10)?
273273
.collect();
274-
274+
275275
assert_eq!(results.len(), 3); // key1, key2, key3 (key4 is exclusive)
276276
assert_eq!(results[0].0, Key::from("key1".to_owned()));
277277
assert_eq!(results[0].1, Value::from("value1".to_owned()));
278-
278+
279279
txn.rollback()?;
280280
Ok(())
281281
}
@@ -298,12 +298,12 @@ fn sync_txn_scan_keys() -> Result<()> {
298298
let keys: Vec<_> = txn
299299
.scan_keys("scan_k1".to_owned()..="scan_k3".to_owned(), 10)?
300300
.collect();
301-
301+
302302
assert_eq!(keys.len(), 3);
303303
assert_eq!(keys[0], Key::from("scan_k1".to_owned()));
304304
assert_eq!(keys[1], Key::from("scan_k2".to_owned()));
305305
assert_eq!(keys[2], Key::from("scan_k3".to_owned()));
306-
306+
307307
txn.rollback()?;
308308
Ok(())
309309
}
@@ -326,13 +326,13 @@ fn sync_txn_scan_reverse() -> Result<()> {
326326
let results: Vec<_> = txn
327327
.scan_reverse("rev1".to_owned()..="rev3".to_owned(), 10)?
328328
.collect();
329-
329+
330330
assert_eq!(results.len(), 3);
331331
// Reverse order: rev3, rev2, rev1
332332
assert_eq!(results[0].0, Key::from("rev3".to_owned()));
333333
assert_eq!(results[1].0, Key::from("rev2".to_owned()));
334334
assert_eq!(results[2].0, Key::from("rev1".to_owned()));
335-
335+
336336
txn.rollback()?;
337337
Ok(())
338338
}
@@ -355,13 +355,13 @@ fn sync_txn_scan_keys_reverse() -> Result<()> {
355355
let keys: Vec<_> = txn
356356
.scan_keys_reverse("revkey1".to_owned()..="revkey3".to_owned(), 10)?
357357
.collect();
358-
358+
359359
assert_eq!(keys.len(), 3);
360360
// Reverse order
361361
assert_eq!(keys[0], Key::from("revkey3".to_owned()));
362362
assert_eq!(keys[1], Key::from("revkey2".to_owned()));
363363
assert_eq!(keys[2], Key::from("revkey1".to_owned()));
364-
364+
365365
txn.rollback()?;
366366
Ok(())
367367
}
@@ -384,9 +384,9 @@ fn sync_txn_scan_with_limit() -> Result<()> {
384384
let results: Vec<_> = txn
385385
.scan("limit_key00".to_owned().., 5)? // Limit to 5 results
386386
.collect();
387-
387+
388388
assert_eq!(results.len(), 5); // Should only get 5 results
389-
389+
390390
txn.rollback()?;
391391
Ok(())
392-
}
392+
}

0 commit comments

Comments
 (0)