summaryrefslogtreecommitdiffstats
path: root/2e412373c47a574a1215756e79e6512a46e30cdc.patch
blob: 9140561336284f57f84955ec3b7a7d48f3fffa57 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
From 2e412373c47a574a1215756e79e6512a46e30cdc Mon Sep 17 00:00:00 2001
From: michael-grunder <michael.grunder@gmail.com>
Date: Fri, 12 Oct 2018 08:36:48 -0700
Subject: [PATCH] Use a ZSET insted of SET for EVAL tests

Redis SET type is unordered which could break our eval tests
so use a ZSET instead where the order is deterministic.
---
 tests/RedisTest.php | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/tests/RedisTest.php b/tests/RedisTest.php
index 28faafa8..e353829d 100644
--- a/tests/RedisTest.php
+++ b/tests/RedisTest.php
@@ -4508,10 +4508,10 @@ public function testEval() {
         $this->redis->rpush('{eval-key}-list', 'c');
 
         // Make a set
-        $this->redis->del('{eval-key}-set');
-        $this->redis->sadd('{eval-key}-set', 'd');
-        $this->redis->sadd('{eval-key}-set', 'e');
-        $this->redis->sadd('{eval-key}-set', 'f');
+        $this->redis->del('{eval-key}-zset');
+        $this->redis->zadd('{eval-key}-zset', 0, 'd');
+        $this->redis->zadd('{eval-key}-zset', 1, 'e');
+        $this->redis->zadd('{eval-key}-zset', 2, 'f');
 
         // Basic keys
         $this->redis->set('{eval-key}-str1', 'hello, world');
@@ -4521,9 +4521,9 @@ public function testEval() {
         $list = $this->redis->eval("return redis.call('lrange', KEYS[1], 0, -1)", Array('{eval-key}-list'), 1);
         $this->assertTrue($list === Array('a','b','c'));
 
-        // Use a script to return our set
-        $set = $this->redis->eval("return redis.call('smembers', KEYS[1])", Array('{eval-key}-set'), 1);
-        $this->assertTrue($set == Array('d','e','f'));
+        // Use a script to return our zset
+        $zset = $this->redis->eval("return redis.call('zrange', KEYS[1], 0, -1)", Array('{eval-key}-zset'), 1);
+        $this->assertTrue($zset == Array('d','e','f'));
 
         // Test an empty MULTI BULK response
         $this->redis->del('{eval-key}-nolist');
@@ -4539,7 +4539,7 @@ public function testEval() {
                     redis.call('get', '{eval-key}-str2'),
                     redis.call('lrange', 'not-any-kind-of-list', 0, -1),
                     {
-                        redis.call('smembers','{eval-key}-set'),
+                        redis.call('zrange','{eval-key}-zset', 0, -1),
                         redis.call('lrange', '{eval-key}-list', 0, -1)
                     }
                 }
@@ -4559,7 +4559,7 @@ public function testEval() {
         );
 
         // Now run our script, and check our values against each other
-        $eval_result = $this->redis->eval($nested_script, Array('{eval-key}-str1', '{eval-key}-str2', '{eval-key}-set', '{eval-key}-list'), 4);
+        $eval_result = $this->redis->eval($nested_script, Array('{eval-key}-str1', '{eval-key}-str2', '{eval-key}-zset', '{eval-key}-list'), 4);
         $this->assertTrue(is_array($eval_result) && count($this->array_diff_recursive($eval_result, $expected)) == 0);
 
         /*