mirror of
https://github.com/facebook/sapling.git
synced 2024-10-10 16:57:49 +03:00
Use NodeHashes instead of Strings for values in bookmarks-test
Summary: In practice, Mononoke requires that the Value associated type of the Bookmarks trait be NodeHash. As a result, in the case of DbBookmarks, rather than making the implementation fully generic over values, I've made it specialized for NodeHashes for simplicity's sake. This means in order to use these tests, they need to store NodeHashes instead of Strings. Reviewed By: farnz Differential Revision: D6217789 fbshipit-source-id: 3f0f04180eb0869eb9de3da7be634d95c2b24d84
This commit is contained in:
parent
83293f1441
commit
43b85874f3
@ -15,6 +15,8 @@ extern crate tokio_core;
|
|||||||
extern crate bookmarks;
|
extern crate bookmarks;
|
||||||
extern crate filebookmarks;
|
extern crate filebookmarks;
|
||||||
extern crate membookmarks;
|
extern crate membookmarks;
|
||||||
|
extern crate mercurial_types;
|
||||||
|
extern crate mercurial_types_mocks;
|
||||||
extern crate storage_types;
|
extern crate storage_types;
|
||||||
|
|
||||||
use std::cell::RefCell;
|
use std::cell::RefCell;
|
||||||
@ -27,16 +29,18 @@ use tokio_core::reactor::Core;
|
|||||||
use bookmarks::BookmarksMut;
|
use bookmarks::BookmarksMut;
|
||||||
use filebookmarks::FileBookmarks;
|
use filebookmarks::FileBookmarks;
|
||||||
use membookmarks::MemBookmarks;
|
use membookmarks::MemBookmarks;
|
||||||
|
use mercurial_types::NodeHash;
|
||||||
|
use mercurial_types_mocks::nodehash;
|
||||||
use storage_types::Version;
|
use storage_types::Version;
|
||||||
|
|
||||||
fn basic<B>(bookmarks: B, core: &mut Core)
|
fn basic<B>(bookmarks: B, core: &mut Core)
|
||||||
where
|
where
|
||||||
B: BookmarksMut<Value = String>,
|
B: BookmarksMut<Value = NodeHash>,
|
||||||
{
|
{
|
||||||
let foo = "foo".to_string();
|
let foo = b"foo";
|
||||||
let one = "1".to_string();
|
let one = nodehash::ONES_HASH;
|
||||||
let two = "2".to_string();
|
let two = nodehash::TWOS_HASH;
|
||||||
let three = "3".to_string();
|
let three = nodehash::THREES_HASH;
|
||||||
|
|
||||||
assert_eq!(core.run(bookmarks.get(&foo)).unwrap(), None);
|
assert_eq!(core.run(bookmarks.get(&foo)).unwrap(), None);
|
||||||
|
|
||||||
@ -77,21 +81,16 @@ where
|
|||||||
|
|
||||||
fn list<B>(bookmarks: B, core: &mut Core)
|
fn list<B>(bookmarks: B, core: &mut Core)
|
||||||
where
|
where
|
||||||
B: BookmarksMut<Value = String>,
|
B: BookmarksMut<Value = NodeHash>,
|
||||||
{
|
{
|
||||||
let one = b"1";
|
let one = b"1";
|
||||||
let two = b"2";
|
let two = b"2";
|
||||||
let three = b"3";
|
let three = b"3";
|
||||||
|
let hash = nodehash::ONES_HASH;
|
||||||
|
|
||||||
let _ = core.run(bookmarks.create(&one, &"foo".to_string()))
|
let _ = core.run(bookmarks.create(&one, &hash)).unwrap().unwrap();
|
||||||
.unwrap()
|
let _ = core.run(bookmarks.create(&two, &hash)).unwrap().unwrap();
|
||||||
.unwrap();
|
let _ = core.run(bookmarks.create(&three, &hash)).unwrap().unwrap();
|
||||||
let _ = core.run(bookmarks.create(&two, &"bar".to_string()))
|
|
||||||
.unwrap()
|
|
||||||
.unwrap();
|
|
||||||
let _ = core.run(bookmarks.create(&three, &"baz".to_string()))
|
|
||||||
.unwrap()
|
|
||||||
.unwrap();
|
|
||||||
|
|
||||||
let mut result = core.run(bookmarks.keys().collect()).unwrap();
|
let mut result = core.run(bookmarks.keys().collect()).unwrap();
|
||||||
result.sort();
|
result.sort();
|
||||||
@ -103,10 +102,10 @@ where
|
|||||||
fn persistence<F, B>(mut new_bookmarks: F, core: Rc<RefCell<Core>>)
|
fn persistence<F, B>(mut new_bookmarks: F, core: Rc<RefCell<Core>>)
|
||||||
where
|
where
|
||||||
F: FnMut() -> B,
|
F: FnMut() -> B,
|
||||||
B: BookmarksMut<Value = String>,
|
B: BookmarksMut<Value = NodeHash>,
|
||||||
{
|
{
|
||||||
let foo = "foo".to_string();
|
let foo = b"foo";
|
||||||
let bar = "bar".to_string();
|
let bar = nodehash::ONES_HASH;
|
||||||
|
|
||||||
let version = {
|
let version = {
|
||||||
let bookmarks = new_bookmarks();
|
let bookmarks = new_bookmarks();
|
||||||
|
Loading…
Reference in New Issue
Block a user