Skip to content

Commit

Permalink
compat table + script (#23)
Browse files Browse the repository at this point in the history
* moving ioredis to a dev dependency

* adding redis-commands dep

* adding ioredis as a peer dep

* adding script that generates compat table

* semicolons missing in example.js

* updated readme with link to compat table

* adding script hooks for npm version/publish

* 1.0.6

* fix linting
  • Loading branch information
stipsan authored Jun 14, 2016
1 parent 61f8306 commit ac4b108
Show file tree
Hide file tree
Showing 5 changed files with 210 additions and 24 deletions.
22 changes: 3 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,25 +39,9 @@ var redis = new RedisMock({
// Basically use it just like ioredis
```

## Mocked ioredis features
## [Mocked ioredis features](compat.md)

* incr
* get
* set
* hsetnx
* hmset
* sadd
* srem
* hget
* hvals
* hgetall
* smembers
* sismember
* hset
* multi
* exec

# Roadmap
## Roadmap
This project started off as just an utility in [another project](https://github.com/stipsan/epic) and just recently got open sourced to benefit the rest of the ioredis community. This means there's work to do before it's feature complete:
- [x] Setup testing suite for the library itself.
- [ ] Refactor to bluebird promises like ioredis, support node style callback too.
Expand All @@ -67,6 +51,6 @@ This project started off as just an utility in [another project](https://github.
- [ ] Pub/Sub
- [ ] Error Handling

# I need a feature not listed here
## I need a feature not listed here

Just create an issue and tell us all about it or submit a PR with it! :-)
175 changes: 175 additions & 0 deletions compat.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,175 @@
| redis | ioredis | ioredis-mock |
|-------|:-------:|:------------:|
|append|:white_check_mark:|:x:|
|asking|:white_check_mark:|:x:|
|auth|:white_check_mark:|:x:|
|bgrewriteaof|:white_check_mark:|:x:|
|bgsave|:white_check_mark:|:x:|
|bitcount|:white_check_mark:|:x:|
|bitfield|:white_check_mark:|:x:|
|bitop|:white_check_mark:|:x:|
|bitpos|:white_check_mark:|:x:|
|blpop|:white_check_mark:|:x:|
|brpop|:white_check_mark:|:x:|
|brpoplpush|:white_check_mark:|:x:|
|client|:white_check_mark:|:x:|
|cluster|:white_check_mark:|:x:|
|command|:white_check_mark:|:x:|
|config|:white_check_mark:|:x:|
|dbsize|:white_check_mark:|:x:|
|debug|:white_check_mark:|:x:|
|decr|:white_check_mark:|:x:|
|decrby|:white_check_mark:|:x:|
|del|:white_check_mark:|:x:|
|discard|:white_check_mark:|:x:|
|dump|:white_check_mark:|:x:|
|echo|:white_check_mark:|:x:|
|eval|:white_check_mark:|:x:|
|evalsha|:white_check_mark:|:x:|
|exec|:white_check_mark:|:white_check_mark:|
|exists|:white_check_mark:|:x:|
|expire|:white_check_mark:|:x:|
|expireat|:white_check_mark:|:x:|
|flushall|:white_check_mark:|:x:|
|flushdb|:white_check_mark:|:x:|
|geoadd|:white_check_mark:|:x:|
|geodist|:white_check_mark:|:x:|
|geohash|:white_check_mark:|:x:|
|geopos|:white_check_mark:|:x:|
|georadius|:white_check_mark:|:x:|
|georadiusbymember|:white_check_mark:|:x:|
|get|:white_check_mark:|:x:|
|getbit|:white_check_mark:|:x:|
|getrange|:white_check_mark:|:x:|
|getset|:white_check_mark:|:x:|
|hdel|:white_check_mark:|:x:|
|hexists|:white_check_mark:|:x:|
|hget|:white_check_mark:|:white_check_mark:|
|hgetall|:white_check_mark:|:white_check_mark:|
|hincrby|:white_check_mark:|:x:|
|hincrbyfloat|:white_check_mark:|:x:|
|hkeys|:white_check_mark:|:x:|
|hlen|:white_check_mark:|:x:|
|hmget|:white_check_mark:|:x:|
|hmset|:white_check_mark:|:white_check_mark:|
|hscan|:white_check_mark:|:x:|
|hset|:white_check_mark:|:white_check_mark:|
|hsetnx|:white_check_mark:|:white_check_mark:|
|hstrlen|:white_check_mark:|:x:|
|hvals|:white_check_mark:|:white_check_mark:|
|incr|:white_check_mark:|:white_check_mark:|
|incrby|:white_check_mark:|:x:|
|incrbyfloat|:white_check_mark:|:x:|
|info|:white_check_mark:|:x:|
|keys|:white_check_mark:|:x:|
|lastsave|:white_check_mark:|:x:|
|latency|:white_check_mark:|:x:|
|lindex|:white_check_mark:|:x:|
|linsert|:white_check_mark:|:x:|
|llen|:white_check_mark:|:x:|
|lpop|:white_check_mark:|:x:|
|lpush|:white_check_mark:|:x:|
|lpushx|:white_check_mark:|:x:|
|lrange|:white_check_mark:|:x:|
|lrem|:white_check_mark:|:x:|
|lset|:white_check_mark:|:x:|
|ltrim|:white_check_mark:|:x:|
|mget|:white_check_mark:|:x:|
|migrate|:white_check_mark:|:x:|
|monitor|:white_check_mark:|:x:|
|move|:white_check_mark:|:x:|
|mset|:white_check_mark:|:x:|
|msetnx|:white_check_mark:|:x:|
|multi|:white_check_mark:|:white_check_mark:|
|object|:white_check_mark:|:x:|
|persist|:white_check_mark:|:x:|
|pexpire|:white_check_mark:|:x:|
|pexpireat|:white_check_mark:|:x:|
|pfadd|:white_check_mark:|:x:|
|pfcount|:white_check_mark:|:x:|
|pfdebug|:white_check_mark:|:x:|
|pfmerge|:white_check_mark:|:x:|
|pfselftest|:white_check_mark:|:x:|
|ping|:white_check_mark:|:x:|
|psetex|:white_check_mark:|:x:|
|psubscribe|:white_check_mark:|:x:|
|psync|:white_check_mark:|:x:|
|pttl|:white_check_mark:|:x:|
|publish|:white_check_mark:|:x:|
|pubsub|:white_check_mark:|:x:|
|punsubscribe|:white_check_mark:|:x:|
|quit|:white_check_mark:|:x:|
|randomkey|:white_check_mark:|:x:|
|readonly|:white_check_mark:|:x:|
|readwrite|:white_check_mark:|:x:|
|rename|:white_check_mark:|:x:|
|renamenx|:white_check_mark:|:x:|
|replconf|:white_check_mark:|:x:|
|restore|:white_check_mark:|:x:|
|restore-asking|:white_check_mark:|:x:|
|role|:white_check_mark:|:x:|
|rpop|:white_check_mark:|:x:|
|rpoplpush|:white_check_mark:|:x:|
|rpush|:white_check_mark:|:x:|
|rpushx|:white_check_mark:|:x:|
|sadd|:white_check_mark:|:white_check_mark:|
|save|:white_check_mark:|:x:|
|scan|:white_check_mark:|:x:|
|scard|:white_check_mark:|:x:|
|script|:white_check_mark:|:x:|
|sdiff|:white_check_mark:|:x:|
|sdiffstore|:white_check_mark:|:x:|
|select|:white_check_mark:|:x:|
|set|:white_check_mark:|:x:|
|setbit|:white_check_mark:|:x:|
|setex|:white_check_mark:|:x:|
|setnx|:white_check_mark:|:x:|
|setrange|:white_check_mark:|:x:|
|shutdown|:white_check_mark:|:x:|
|sinter|:white_check_mark:|:x:|
|sinterstore|:white_check_mark:|:x:|
|sismember|:white_check_mark:|:white_check_mark:|
|slaveof|:white_check_mark:|:x:|
|slowlog|:white_check_mark:|:x:|
|smembers|:white_check_mark:|:white_check_mark:|
|smove|:white_check_mark:|:x:|
|sort|:white_check_mark:|:x:|
|spop|:white_check_mark:|:x:|
|srandmember|:white_check_mark:|:x:|
|srem|:white_check_mark:|:white_check_mark:|
|sscan|:white_check_mark:|:x:|
|strlen|:white_check_mark:|:x:|
|subscribe|:white_check_mark:|:x:|
|substr|:white_check_mark:|:x:|
|sunion|:white_check_mark:|:x:|
|sunionstore|:white_check_mark:|:x:|
|sync|:white_check_mark:|:x:|
|time|:white_check_mark:|:x:|
|ttl|:white_check_mark:|:x:|
|type|:white_check_mark:|:x:|
|unlink|:white_check_mark:|:x:|
|unsubscribe|:white_check_mark:|:x:|
|unwatch|:white_check_mark:|:x:|
|wait|:white_check_mark:|:x:|
|watch|:white_check_mark:|:x:|
|zadd|:white_check_mark:|:x:|
|zcard|:white_check_mark:|:x:|
|zcount|:white_check_mark:|:x:|
|zincrby|:white_check_mark:|:x:|
|zinterstore|:white_check_mark:|:x:|
|zlexcount|:white_check_mark:|:x:|
|zrange|:white_check_mark:|:x:|
|zrangebylex|:white_check_mark:|:x:|
|zrangebyscore|:white_check_mark:|:x:|
|zrank|:white_check_mark:|:x:|
|zrem|:white_check_mark:|:x:|
|zremrangebylex|:white_check_mark:|:x:|
|zremrangebyrank|:white_check_mark:|:x:|
|zremrangebyscore|:white_check_mark:|:x:|
|zrevrange|:white_check_mark:|:x:|
|zrevrangebylex|:white_check_mark:|:x:|
|zrevrangebyscore|:white_check_mark:|:x:|
|zrevrank|:white_check_mark:|:x:|
|zscan|:white_check_mark:|:x:|
|zscore|:white_check_mark:|:x:|
|zunionstore|:white_check_mark:|:x:|
4 changes: 2 additions & 2 deletions example.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
var RedisMock = require('ioredis-mock').default
var RedisMock = require('ioredis-mock').default;
var redis = new RedisMock({
data: {
user_next: '3',
Expand All @@ -11,4 +11,4 @@ var redis = new RedisMock({
}
});

await redis.incr('user_next')
await redis.incr('user_next');
12 changes: 9 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
{
"name": "ioredis-mock",
"version": "1.0.5",
"version": "1.0.6",
"description": "This library emulates ioredis by performing all operations in-memory.",
"main": "./lib",
"scripts": {
"clean": "rimraf lib",
"prepublish": "npm run clean && npm run build",
"preversion": "node scripts/update-compat",
"build": "mkdirp lib && babel src --out-file lib/index.js",
"build:watch": "npm run build -- --watch",
"test": "mocha --compilers js:babel-register --recursive",
Expand All @@ -28,6 +30,9 @@
},
"tonicExampleFilename": "example.js",
"homepage": "https://github.com/stipsan/ioredis-mock#readme",
"peerDependencies": {
"ioredis": "2.x"
},
"devDependencies": {
"babel-cli": "6.10.1",
"babel-eslint": "6.0.4",
Expand All @@ -41,13 +46,14 @@
"eslint-plugin-import": "1.8.1",
"expect": "1.20.1",
"growl": "1.9.2",
"ioredis": "2.0.1",
"istanbul": "1.0.0-alpha.2",
"mkdirp": "0.5.1",
"mocha": "2.5.3",
"rimraf": "2.5.2"
},
"dependencies": {
"ioredis": "2.0.1",
"lodash": "4.13.1"
"lodash": "4.13.1",
"redis-commands": "1.2.0"
}
}
21 changes: 21 additions & 0 deletions scripts/update-compat.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
const path = require('path');
const fs = require('fs');
const commands = require('redis-commands');
const redis = require('ioredis');
const redisMock = require('..').default;

let tableMd = `
### Supported commands
| redis | ioredis | ioredis-mock |
|-------|:-------:|:------------:|`;
commands.list.forEach(command => {
const redisCol = `${command}`;
const ioredisCol = command in redis.prototype ? ':white_check_mark:' : ':x:';
const ioredisMockCol = command in redisMock.prototype ? ':white_check_mark:' : ':x:';
tableMd += `
|${redisCol}|${ioredisCol}|${ioredisMockCol}|`;
});

fs.writeFile(path.resolve('..', 'compat.md'), tableMd, (err) => {
if (err) throw err;
});

0 comments on commit ac4b108

Please sign in to comment.