-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathresp3.rs
52 lines (43 loc) · 1.37 KB
/
resp3.rs
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
use crate::{
commands::{
ConnectionCommands, FlushingMode, HelloOptions, ServerCommands, SortedSetCommands,
StringCommands,
},
tests::get_test_client,
Result,
};
use serial_test::serial;
#[cfg_attr(feature = "tokio-runtime", tokio::test)]
#[cfg_attr(feature = "async-std-runtime", async_std::test)]
#[serial]
async fn double() -> Result<()> {
let client = get_test_client().await?;
client.flushdb(FlushingMode::Sync).await?;
client.hello(HelloOptions::new(3)).await?;
client
.zadd(
"key",
[(1.1, "one"), (2.2, "two"), (3.3, "three")],
Default::default(),
)
.await?;
let values: Vec<(String, f64)> = client
.zrange_with_scores("key", 0, -1, Default::default())
.await?;
assert_eq!(3, values.len());
assert_eq!(("one".to_owned(), 1.1), values[0]);
assert_eq!(("two".to_owned(), 2.2), values[1]);
assert_eq!(("three".to_owned(), 3.3), values[2]);
Ok(())
}
#[cfg_attr(feature = "tokio-runtime", tokio::test)]
#[cfg_attr(feature = "async-std-runtime", async_std::test)]
#[serial]
async fn null() -> Result<()> {
let client = get_test_client().await?;
client.flushdb(FlushingMode::Sync).await?;
client.hello(HelloOptions::new(3)).await?;
let value: Option<String> = client.get("key").await?;
assert_eq!(None, value);
Ok(())
}