From 37fa8a2043233c7e96422f46a4c7200f20a9cb0f Mon Sep 17 00:00:00 2001 From: Vika Date: Thu, 22 Jun 2023 22:34:00 +0300 Subject: 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. --- kittybox-rs/src/database/mod.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'kittybox-rs/src/database') 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::() ); + let time = chrono::Local::now().to_rfc3339(); let post = json!({ "type": ["h-entry"], "properties": { "content": [rand::random::().to_string()], "uid": [&uid], - "url": [&uid] + "url": [&uid], + "published": [&time] } }); @@ -558,6 +560,9 @@ mod tests { async fn test_feed_pagination(backend: Backend) { let posts = std::iter::from_fn(|| Some(gen_random_post("fireburn.ru"))) .take(20) + .collect::>() + .into_iter() + .rev() .collect::>(); 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 -- cgit 1.4.1