|
@@ -25,10 +25,9 @@ mod test {
|
|
|
io::{BufRead, BufReader},
|
|
|
};
|
|
|
|
|
|
- fn setup_db<'a, T, I>(db: &'a T)
|
|
|
+ fn setup_db<T>(db: &T)
|
|
|
where
|
|
|
- T: Storage<'a, I>,
|
|
|
- I: Iterator<Item = Result<Event, Error>>,
|
|
|
+ T: Storage,
|
|
|
{
|
|
|
let file = File::open("./tests/events.json").expect("file");
|
|
|
let events = BufReader::new(file)
|
|
@@ -41,10 +40,9 @@ mod test {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- pub fn store_and_get<'a, T, I>(db: &'a T)
|
|
|
+ pub fn store_and_get<T>(db: &T)
|
|
|
where
|
|
|
- T: Storage<'a, I>,
|
|
|
- I: Iterator<Item = Result<Event, Error>>,
|
|
|
+ T: Storage,
|
|
|
{
|
|
|
let json = "{\"content\":\"{\\\"lud06\\\":\\\"lnbc1p3a4wxvpp5x0pa6gr55fq5s9d3dxs0vz77mqxgdw63hhtgtlfz5zvm65847vnqdqqcqpjsp5402c8rtqxd4j97rnvuejuwl4sg473g6wg08d67fvn7qc4gtpkfks9q7sqqqqqqqqqqqqqqqqqqqsqqqqqysgqmqz9gxqyjw5qrzjqwryaup9lh50kkranzgcdnn2fgvx390wgj5jd07rwr3vxeje0glclleasn65surjcsqqqqlgqqqqqeqqjqyxj968tem9ps6ttm9ukv6ag4yc6qmgj2svrccfgp4n83fpktr3dsx6fq7grfzlqt982aaemahg9q29vzl9f627kh4j8h8xc2z2mtpdqqjlekah\\\",\\\"website\\\":\\\"\\\",\\\"nip05\\\":\\\"cesar@cesar.com.py\\\",\\\"picture\\\":\\\"https://pbs.twimg.com/profile_images/1175432935337537536/_Peu9vuJ_400x400.jpg\\\",\\\"display_name\\\":\\\"C\\\",\\\"about\\\":\\\"Rust and PHP\\\",\\\"name\\\":\\\"c\\\"}\",\"created_at\":1678476588,\"id\":\"3800c787a23288641c0b96cbcc87c26cbd3ea7bee53b7748422fdb100fb7b9f0\",\"kind\":0,\"pubkey\":\"b2815682cfc83fcd2c3add05785cf4573dd388457069974cc6d8cca06b3c3b78\",\"sig\":\"c8a12ce96833e4cd67bce0e9e50f831262ef0f0c0cff5e56c38a0c90867ed1a6621e9692948ef5e85a7ca3726c3f0f43fa7e1992536bc457317123bca8784f5f\",\"tags\":[]}";
|
|
|
|
|
@@ -56,10 +54,9 @@ mod test {
|
|
|
assert_eq!(event1, Some(event));
|
|
|
}
|
|
|
|
|
|
- pub fn records_are_sorted_by_date_desc<'a, T, I>(db: &'a T)
|
|
|
+ pub fn records_are_sorted_by_date_desc<T>(db: &T)
|
|
|
where
|
|
|
- T: Storage<'a, I>,
|
|
|
- I: Iterator<Item = Result<Event, Error>>,
|
|
|
+ T: Storage,
|
|
|
{
|
|
|
setup_db(db);
|
|
|
|
|
@@ -85,10 +82,9 @@ mod test {
|
|
|
assert_eq!(dates, sorted_dates);
|
|
|
}
|
|
|
|
|
|
- pub fn filter_by_references<'a, T, I>(db: &'a T)
|
|
|
+ pub fn filter_by_references<T>(db: &T)
|
|
|
where
|
|
|
- T: Storage<'a, I>,
|
|
|
- I: Iterator<Item = Result<Event, Error>>,
|
|
|
+ T: Storage,
|
|
|
{
|
|
|
setup_db(db);
|
|
|
|
|
@@ -112,10 +108,9 @@ mod test {
|
|
|
assert_eq!(related_events.len(), 1);
|
|
|
}
|
|
|
|
|
|
- pub fn filter_by_references_zero_match<'a, T, I>(db: &'a T)
|
|
|
+ pub fn filter_by_references_zero_match<T>(db: &T)
|
|
|
where
|
|
|
- T: Storage<'a, I>,
|
|
|
- I: Iterator<Item = Result<Event, Error>>,
|
|
|
+ T: Storage,
|
|
|
{
|
|
|
setup_db(db);
|
|
|
|
|
@@ -139,10 +134,9 @@ mod test {
|
|
|
assert_eq!(related_events.len(), 0);
|
|
|
}
|
|
|
|
|
|
- pub fn filter_by_references_and_kind<'a, T, I>(db: &'a T)
|
|
|
+ pub fn filter_by_references_and_kind<T>(db: &T)
|
|
|
where
|
|
|
- T: Storage<'a, I>,
|
|
|
- I: Iterator<Item = Result<Event, Error>>,
|
|
|
+ T: Storage,
|
|
|
{
|
|
|
setup_db(db);
|
|
|
|
|
@@ -162,10 +156,9 @@ mod test {
|
|
|
assert_eq!(related_events.len(), 3);
|
|
|
}
|
|
|
|
|
|
- pub fn get_event_and_related_events<'a, T, I>(db: &'a T)
|
|
|
+ pub fn get_event_and_related_events<T>(db: &T)
|
|
|
where
|
|
|
- T: Storage<'a, I>,
|
|
|
- I: Iterator<Item = Result<Event, Error>>,
|
|
|
+ T: Storage,
|
|
|
{
|
|
|
setup_db(db);
|
|
|
|
|
@@ -202,10 +195,9 @@ mod test {
|
|
|
assert_eq!(Kind::Unknown(42), kinds[1]);
|
|
|
}
|
|
|
|
|
|
- pub fn filter_by_authors<'a, T, I>(db: &'a T)
|
|
|
+ pub fn filter_by_authors<T>(db: &T)
|
|
|
where
|
|
|
- T: Storage<'a, I>,
|
|
|
- I: Iterator<Item = Result<Event, Error>>,
|
|
|
+ T: Storage,
|
|
|
{
|
|
|
setup_db(db);
|
|
|
let query = Filter {
|
|
@@ -227,10 +219,9 @@ mod test {
|
|
|
assert_eq!(records.len(), 27);
|
|
|
}
|
|
|
|
|
|
- pub fn filter_by_author<'a, T, I>(db: &'a T)
|
|
|
+ pub fn filter_by_author<T>(db: &T)
|
|
|
where
|
|
|
- T: Storage<'a, I>,
|
|
|
- I: Iterator<Item = Result<Event, Error>>,
|
|
|
+ T: Storage,
|
|
|
{
|
|
|
setup_db(db);
|
|
|
let query = Filter {
|
|
@@ -249,10 +240,9 @@ mod test {
|
|
|
assert_eq!(records.len(), 3);
|
|
|
}
|
|
|
|
|
|
- pub fn filter_by_author_and_kinds<'a, T, I>(db: &'a T)
|
|
|
+ pub fn filter_by_author_and_kinds<T>(db: &T)
|
|
|
where
|
|
|
- T: Storage<'a, I>,
|
|
|
- I: Iterator<Item = Result<Event, Error>>,
|
|
|
+ T: Storage,
|
|
|
{
|
|
|
setup_db(db);
|
|
|
let query = Filter {
|
|
@@ -272,10 +262,9 @@ mod test {
|
|
|
assert_eq!(records.len(), 2);
|
|
|
}
|
|
|
|
|
|
- pub fn filter_kind<'a, T, I>(db: &'a T)
|
|
|
+ pub fn filter_kind<T>(db: &T)
|
|
|
where
|
|
|
- T: Storage<'a, I>,
|
|
|
- I: Iterator<Item = Result<Event, Error>>,
|
|
|
+ T: Storage,
|
|
|
{
|
|
|
setup_db(db);
|
|
|
let query = Filter {
|
|
@@ -294,10 +283,9 @@ mod test {
|
|
|
.for_each(|x| assert_eq!(x, Kind::ShortTextNote));
|
|
|
}
|
|
|
|
|
|
- pub fn get_local_events<'a, T, I>(db: &'a T)
|
|
|
+ pub fn get_local_events<T>(db: &T)
|
|
|
where
|
|
|
- T: Storage<'a, I>,
|
|
|
- I: Iterator<Item = Result<Event, Error>>,
|
|
|
+ T: Storage,
|
|
|
{
|
|
|
setup_db(db);
|
|
|
|