Skip to content

Instantly share code, notes, and snippets.

@jimmycuadra
Last active July 15, 2017 17:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jimmycuadra/e4f251bb77e7acdafc009d487437aa8d to your computer and use it in GitHub Desktop.
Save jimmycuadra/e4f251bb77e7acdafc009d487437aa8d to your computer and use it in GitHub Desktop.
#[test]
fn create_in_order() {
let core = Core::new().unwrap();
let mut client = TestClient::new(core);
let requests: Vec<FutureKeySpaceInfo> = (1..4).map(|_| {
kv::create_in_order( &client, "/test/foo", "bar", None)
}).collect();
let work = join_all(requests).and_then(|mut ksis: Vec<KeySpaceInfo>| {
ksis.sort_by_key(|ksi| ksi.node.as_ref().unwrap().modified_index.unwrap());
let keys: Vec<String> = ksis
.into_iter()
.map(|ksi| ksi.node.unwrap().key.unwrap())
.collect();
assert!(keys[0] < keys[1]);
assert!(keys[1] < keys[2]);
Ok(())
});
assert!(client.run(work).is_ok());
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment