redis.client.Test.js 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. "use strict";
  2. var RedisClient = require('../../../../src/server/repository/redis/redis.client');
  3. let redisClient = RedisClient.redisClient();
  4. let redisConn = redisClient.connection;
  5. var assert = require('assert');
  6. describe('Redis Client', function () {
  7. describe('When connected successfully', function () {
  8. it('should ok with set/get string async', function (done) {
  9. redisConn.setAsync('hello', 'world').then(function (res) {
  10. assert.strictEqual(res, 'OK');
  11. });
  12. redisConn.getAsync('hello').then(function (res) {
  13. assert.strictEqual(res, 'world');
  14. done();
  15. });
  16. });
  17. });
  18. describe('When sadd/srem with set', function () {
  19. it('should ok', function (done) {
  20. redisConn.sadd('set', 'a', 'b', 'c');
  21. redisConn.smembers('set', function (err, res) {
  22. assert.strictEqual(res.length, 3);
  23. redisConn.srem('set', 'a', 'b', 'c');
  24. done();
  25. });
  26. });
  27. });
  28. });