From a74e1abd1a48ed6a9be5f80bdff60b08e38a2591 Mon Sep 17 00:00:00 2001 From: Yilin Chen Date: Mon, 12 Aug 2019 14:08:49 +0800 Subject: [PATCH] Fix tests Signed-off-by: Yilin Chen --- Cargo.toml | 4 ++-- examples/transaction.rs | 2 +- src/transaction/mod.rs | 22 +++++++++------------- 3 files changed, 12 insertions(+), 16 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 7f6af9d..cfb67b3 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -38,7 +38,7 @@ features = ["push", "process"] [dev-dependencies] clap = "2.32" tempdir = "0.3" -runtime = "0.3.0-alpha.3" -runtime-tokio = "0.3.0-alpha.3" +runtime = { version = "0.3.0-alpha.6", default-features = false } +runtime-tokio = "0.3.0-alpha.5" proptest = "0.9" proptest-derive = "0.1.0" diff --git a/examples/transaction.rs b/examples/transaction.rs index e7ad532..b53b88d 100644 --- a/examples/transaction.rs +++ b/examples/transaction.rs @@ -18,7 +18,7 @@ async fn puts(client: &Client, pairs: impl IntoIterator txn.commit().await.expect("Could not commit transaction"); } -async fn get(client: &Client, key: Key) -> Value { +async fn get(client: &Client, key: Key) -> Option { let txn = client.begin().await.expect("Could not begin a transaction"); txn.get(key).await.expect("Could not get value") } diff --git a/src/transaction/mod.rs b/src/transaction/mod.rs index b2de856..26a58eb 100644 --- a/src/transaction/mod.rs +++ b/src/transaction/mod.rs @@ -106,8 +106,7 @@ impl Transaction { /// # let connected_client = connecting_client.await.unwrap(); /// let mut txn = connected_client.begin().await.unwrap(); /// let key = "TiKV".to_owned(); - /// let req = txn.get(key); - /// let result: Value = req.await.unwrap(); + /// let result: Option = txn.get(key).await.unwrap(); /// // Finish the transaction... /// txn.commit().await.unwrap(); /// # }); @@ -125,15 +124,15 @@ impl Transaction { /// /// ```rust,no_run /// # #![feature(async_await)] - /// # use tikv_client::{KvPair, Config, transaction::Client}; + /// # use tikv_client::{Key, Value, Config, transaction::Client}; /// # use futures::prelude::*; + /// # use std::collections::HashMap; /// # futures::executor::block_on(async { /// # let connecting_client = Client::connect(Config::new(vec!["192.168.0.100", "192.168.0.101"])); /// # let connected_client = connecting_client.await.unwrap(); /// let mut txn = connected_client.begin().await.unwrap(); /// let keys = vec!["TiKV".to_owned(), "TiDB".to_owned()]; - /// let req = txn.batch_get(keys); - /// let result: Result> = req.await.unwrap(); + /// let result: HashMap = txn.batch_get(keys).await.unwrap(); /// // Finish the transaction... /// txn.commit().await.unwrap(); /// # }); @@ -343,8 +342,7 @@ impl Snapshot { /// # let connected_client = connecting_client.await.unwrap(); /// let snapshot = connected_client.snapshot().await.unwrap(); /// let key = "TiKV".to_owned(); - /// let req = snapshot.get(key); - /// let result: Value = req.await.unwrap(); + /// let result: Option = snapshot.get(key).await.unwrap(); /// # }); /// ``` pub async fn get(&self, _key: impl Into) -> Result> { @@ -356,17 +354,15 @@ impl Snapshot { /// /// ```rust,no_run /// # #![feature(async_await)] - /// # use tikv_client::{KvPair, Config, TransactionClient}; + /// # use tikv_client::{Key, Value, Config, TransactionClient}; /// # use futures::prelude::*; + /// # use std::collections::HashMap; /// # futures::executor::block_on(async { /// # let connecting_client = TransactionClient::connect(Config::new(vec!["192.168.0.100", "192.168.0.101"])); /// # let connected_client = connecting_client.await.unwrap(); - /// let mut txn = connected_client.begin().await.unwrap(); + /// let snapshot = connected_client.snapshot().await.unwrap(); /// let keys = vec!["TiKV".to_owned(), "TiDB".to_owned()]; - /// let req = txn.batch_get(keys); - /// let result: Result> = req.await.unwrap(); - /// // Finish the transaction... - /// txn.commit().await.unwrap(); + /// let result: HashMap = snapshot.batch_get(keys).await.unwrap(); /// # }); /// ``` pub async fn batch_get(