Update and delete in integration tests

Signed-off-by: Yilin Chen <sticnarf@gmail.com>
This commit is contained in:
Yilin Chen 2019-09-25 13:02:35 +08:00
parent 3ab4252e1d
commit 4c6ab294ef
No known key found for this signature in database
GPG Key ID: 353E7ED34BF326E0
1 changed files with 18 additions and 2 deletions

View File

@ -68,8 +68,8 @@ fn crud() -> Fallible<()> {
);
txn.commit().await?;
// Read again from TiKV
let txn = client.begin().await?;
// Read from TiKV then update and delete
let mut txn = client.begin().await?;
assert_eq!(
txn.get("foo".to_owned()).await?,
Some("bar".to_owned().into())
@ -87,6 +87,22 @@ fn crud() -> Fallible<()> {
batch_get_res.get(&Key::from("bar".to_owned())),
Some(Value::from("foo".to_owned())).as_ref()
);
txn.set("foo".to_owned(), "foo".to_owned()).await?;
txn.delete("bar".to_owned()).await?;
txn.commit().await?;
// Read again from TiKV
let txn = client.begin().await?;
let batch_get_res: HashMap<Key, Value> = txn
.batch_get(vec!["foo".to_owned(), "bar".to_owned()])
.await?
.filter_map(|(k, v)| v.map(|v| (k, v)))
.collect();
assert_eq!(
batch_get_res.get(&Key::from("foo".to_owned())),
Some(Value::from("foo".to_owned())).as_ref()
);
assert_eq!(batch_get_res.get(&Key::from("bar".to_owned())), None);
Fallible::Ok(())
})
}