Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Dont' assume SET ordering in tests #326

Closed
wants to merge 1 commit into from

2 participants

@gjohnson

Small fix to test assertions for sadd/smembers. Simply checks the index of the member rather than assuming ordering on a SET, since they don't guarantee order and all.

Error used to be:

- sadd2:
Uncaught exception: AssertionError: "member2" === "member0"
    at tests.SADD2 (/Users/gjohnson/Projects/bitcrunch/node_modules/redis/test.js:998:16)
    at try_callback (/Users/gjohnson/Projects/bitcrunch/node_modules/redis/index.js:520:9)
    at RedisClient.return_reply (/Users/gjohnson/Projects/bitcrunch/node_modules/redis/index.js:590:13)
    at ReplyParser.RedisClient.init_parser (/Users/gjohnson/Projects/bitcrunch/node_modules/redis/index.js:263:14)
    at ReplyParser.EventEmitter.emit (events.js:96:17)
    at ReplyParser.send_reply (/Users/gjohnson/Projects/bitcrunch/node_modules/redis/lib/parser/javascript.js:297:10)
    at ReplyParser.execute (/Users/gjohnson/Projects/bitcrunch/node_modules/redis/lib/parser/javascript.js:211:22)
    at RedisClient.on_data (/Users/gjohnson/Projects/bitcrunch/node_modules/redis/index.js:476:27)
    at Socket.<anonymous> (/Users/gjohnson/Projects/bitcrunch/node_modules/redis/index.js:79:14)
    at Socket.EventEmitter.emit (events.js:96:17)
@DTrejo DTrejo closed this pull request from a commit
Garrett Johnson test.js: smembers reply should not assume order, b/c sets do not ensu…
…re order

Closes #326.

Signed-off-by: DTrejo <david.daniel.trejo@gmail.com>
b5a57b4
@DTrejo DTrejo closed this in b5a57b4
@DTrejo
Collaborator

Thank you!
D

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Nov 3, 2012
  1. Changes test assertion on smembers reply to not assume order because …

    Garrett Johnson authored
    …sets to not ensure order.
This page is out of date. Refresh to see the latest.
Showing with 6 additions and 6 deletions.
  1. +6 −6 test.js
View
12 test.js
@@ -994,16 +994,16 @@ tests.SADD2 = function () {
client.sadd("set0", ["member0", "member1", "member2"], require_number(3, name));
client.smembers("set0", function (err, res) {
assert.strictEqual(res.length, 3);
- assert.strictEqual(res[0], "member0");
- assert.strictEqual(res[1], "member1");
- assert.strictEqual(res[2], "member2");
+ assert.ok(~res.indexOf("member0"));
+ assert.ok(~res.indexOf("member1"));
+ assert.ok(~res.indexOf("member2"));
});
client.SADD("set1", ["member0", "member1", "member2"], require_number(3, name));
client.smembers("set1", function (err, res) {
assert.strictEqual(res.length, 3);
- assert.strictEqual(res[0], "member0");
- assert.strictEqual(res[1], "member1");
- assert.strictEqual(res[2], "member2");
+ assert.ok(~res.indexOf("member0"));
+ assert.ok(~res.indexOf("member1"));
+ assert.ok(~res.indexOf("member2"));
next(name);
});
};
Something went wrong with that request. Please try again.