diff options
author | Vika <vika@fireburn.ru> | 2023-06-22 22:34:00 +0300 |
---|---|---|
committer | Vika <vika@fireburn.ru> | 2023-06-22 22:34:00 +0300 |
commit | 37fa8a2043233c7e96422f46a4c7200f20a9cb0f (patch) | |
tree | ec2c3aaecda013800feb13b351ce3b57edd60714 | |
parent | bf499c9351cdfa88002cc7eaf2f695b0683efa5b (diff) | |
download | kittybox-37fa8a2043233c7e96422f46a4c7200f20a9cb0f.tar.zst |
database: more realistic pagination test
We insert published time into all objects anyway, and expect feeds to be ordered by publishing time. We should let databases rely on that assumption when returning feeds.
-rw-r--r-- | kittybox-rs/src/database/mod.rs | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/kittybox-rs/src/database/mod.rs b/kittybox-rs/src/database/mod.rs index cb4c0b9..94a93ca 100644 --- a/kittybox-rs/src/database/mod.rs +++ b/kittybox-rs/src/database/mod.rs @@ -543,12 +543,14 @@ mod tests { rand::random::<Word>() ); + let time = chrono::Local::now().to_rfc3339(); let post = json!({ "type": ["h-entry"], "properties": { "content": [rand::random::<Paragraphs>().to_string()], "uid": [&uid], - "url": [&uid] + "url": [&uid], + "published": [&time] } }); @@ -558,6 +560,9 @@ mod tests { async fn test_feed_pagination<Backend: Storage>(backend: Backend) { let posts = std::iter::from_fn(|| Some(gen_random_post("fireburn.ru"))) .take(20) + .collect::<Vec<serde_json::Value>>() + .into_iter() + .rev() .collect::<Vec<serde_json::Value>>(); let feed = json!({ @@ -596,6 +601,7 @@ mod tests { println!("feed[0][{}] = {}", i, post["properties"]["uid"][0]); } println!("---"); + assert!(result["children"].as_array().unwrap().len() <= limit); assert_eq!(result["children"].as_array().unwrap()[0..10], posts[0..10]); let result2 = backend |