From 25a5151fcdebd64b207f7b0f0bc5e2836787b5d6 Mon Sep 17 00:00:00 2001 From: gillchristian Date: Sun, 20 Oct 2024 12:39:12 +0200 Subject: [PATCH] Simpler assertions on keys test --- tests/integration.rs | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/tests/integration.rs b/tests/integration.rs index 99434ae..d84432e 100644 --- a/tests/integration.rs +++ b/tests/integration.rs @@ -350,16 +350,21 @@ async fn test_getrange() { #[serial] async fn test_keys() { test_compare::>(|p| { - // Redis keys order is deterministice but not guaranteed. - // We sort the keys by insertion order to make the test deterministic. - // Testing with a different set of keys produces different results, - // but matching the implementation is out of the scope of the project. + // Redis keys order is deterministic (always returning the same order for + // a given set of keys) but not guaranteed (it may change between runs). + // + // We sort in backward chronological order to get deterministic results. + // Matching the implementation is out of the scope of the project. p.cmd("SET").arg("keys_key_1").arg("Argentina"); - p.cmd("SET").arg("keys_key_2").arg("Spain"); - p.cmd("SET").arg("keys_key_3").arg("Netherlands"); p.cmd("KEYS").arg("*"); p.cmd("KEYS").arg("*key*"); + + p.cmd("SET").arg("keys_key_2").arg("Spain"); + p.cmd("SET").arg("keys_key_3").arg("Netherlands"); + + p.cmd("KEYS").arg("*1"); + p.cmd("KEYS").arg("*2"); p.cmd("KEYS").arg("*3"); }) .await;