{"action":"created","comment":{"url":"https://api.github.com/repos/koajs/koa-redis/pulls/comments/49155276","id":49155276,"diff_hunk":"@@ -13,48 +13,119 @@\n  * Module dependencies.\n  */\n \n-var store = require('../')();\n var should = require('should');\n var co = require('co');\n+var redis = require('redis');\n+var redisWrapper = require('co-redis');\n \n describe('test/koa-redis.test.js', function () {\n+  it('should connect and ready with external client and quit ok', function (done) {\n+    var store = require('../')({client: redis.createClient()});\n+    store.once('connect', function() {\n+      store.connected.should.eql(true);\n+      store.once('ready', function() {\n+        co.wrap(function *() {\n+          yield store.quit();\n+        })();\n+      });\n+      store.once('end', function() {\n+        store.connected.should.eql(false);\n+        done();\n+      });\n+    });\n+  });\n+  \n+  it('should connect and ready with duplicated external client and disconnect ok', function (done) {\n+    var store = require('../')({\n+      client: redis.createClient(),\n+      duplicate: true\n+    });\n+    store.once('connect', function() {\n+      store.connected.should.eql(true);\n+      store.on('ready', function() {\n+        co.wrap(function *() {\n+          yield store.end();\n+        })();\n+      });\n+      store.once('disconnect', function() {\n+        store.connected.should.eql(false);\n+        done();\n+      });\n+    });\n+  });\n+  \n+  it('should set with db ok', function (done) {\n+    var store = require('../')({db: 2});\n+    var client = redis.createClient();\n+    client.select(2);\n+    client = redisWrapper(client);\n+    co.wrap(function *() {\n+      yield store.set('key:db1', {a: 1});\n+      (yield store.get('key:db1')).should.eql({a: 1});\n+      JSON.parse(yield client.get('key:db1')).should.eql({a: 1});\n+      yield store.quit();\n+      done();\n+    })();\n+  });\n+  \n   it('should set with ttl ok', function (done) {\n-    co(function *() {\n+    var store = require('../')();\n+    co.wrap(function *() {\n       yield store.set('key:ttl', {a: 1}, 86400000);\n       (yield store.get('key:ttl')).should.eql({a: 1});\n       (yield store.client.ttl('key:ttl')).should.equal(86400);\n+      yield store.quit();\n+      done();\n+    })();\n+  });\n+  \n+  it('should not throw error with bad JSON', function (done) {\n+    var store = require('../')();\n+    co.wrap(function *() {\n+      yield store.client.set('key:badKey', '{I will cause an error!}');\n+      should.not.exist(yield store.get('key:badKey'));\n+      yield store.quit();\n       done();\n     })();\n   });\n \n   it('should set without ttl ok', function (done) {\n-    co(function *() {\n+    var store = require('../')();\n+    co.wrap(function *() {\n       yield store.set('key:nottl', {a: 1});\n       (yield store.get('key:nottl')).should.eql({a: 1});\n       (yield store.client.ttl('key:nottl')).should.equal(-1);\n+      yield store.quit();\n       done();\n     })();\n   });\n+  \n   it('should destroy ok', function (done) {\n-    co(function *() {\n+    var store = require('../')();\n+    co.wrap(function *() {\n       yield store.destroy('key:nottl');\n       yield store.destroy('key:ttl');\n+      yield store.destroy('key:badKey');\n       should.not.exist(yield store.get('key:nottl'));\n       should.not.exist(yield store.get('key:ttl'));\n+      should.not.exist(yield store.get('key:badKey'));\n+      yield store.quit();\n       done();\n     })();\n   });\n \n   it('should expire after 1s', function (done) {","path":"test/koa-redis.test.js","position":117,"original_position":117,"commit_id":"a64752f72381b4a9a6d0a404c8969bf3bc39c6b2","original_commit_id":"32a120f6886b9a5ae6661932c5e7a2d13cb04434","user":{"login":"DaAwesomeP","id":4472083,"avatar_url":"https://avatars.githubusercontent.com/u/4472083?v=3","gravatar_id":"","url":"https://api.github.com/users/DaAwesomeP","html_url":"https://github.com/DaAwesomeP","followers_url":"https://api.github.com/users/DaAwesomeP/followers","following_url":"https://api.github.com/users/DaAwesomeP/following{/other_user}","gists_url":"https://api.github.com/users/DaAwesomeP/gists{/gist_id}","starred_url":"https://api.github.com/users/DaAwesomeP/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DaAwesomeP/subscriptions","organizations_url":"https://api.github.com/users/DaAwesomeP/orgs","repos_url":"https://api.github.com/users/DaAwesomeP/repos","events_url":"https://api.github.com/users/DaAwesomeP/events{/privacy}","received_events_url":"https://api.github.com/users/DaAwesomeP/received_events","type":"User","site_admin":false},"body":"I didn't know that that existed! Will do.","created_at":"2016-01-08T03:22:01Z","updated_at":"2016-01-08T03:22:01Z","html_url":"https://github.com/koajs/koa-redis/pull/13#discussion_r49155276","pull_request_url":"https://api.github.com/repos/koajs/koa-redis/pulls/13","_links":{"self":{"href":"https://api.github.com/repos/koajs/koa-redis/pulls/comments/49155276"},"html":{"href":"https://github.com/koajs/koa-redis/pull/13#discussion_r49155276"},"pull_request":{"href":"https://api.github.com/repos/koajs/koa-redis/pulls/13"}}},"pull_request":{"url":"https://api.github.com/repos/koajs/koa-redis/pulls/13","id":55413237,"html_url":"https://github.com/koajs/koa-redis/pull/13","diff_url":"https://github.com/koajs/koa-redis/pull/13.diff","patch_url":"https://github.com/koajs/koa-redis/pull/13.patch","issue_url":"https://api.github.com/repos/koajs/koa-redis/issues/13","number":13,"state":"open","locked":false,"title":"Add complete support for new redis, fix tests and coverage","user":{"login":"DaAwesomeP","id":4472083,"avatar_url":"https://avatars.githubusercontent.com/u/4472083?v=3","gravatar_id":"","url":"https://api.github.com/users/DaAwesomeP","html_url":"https://github.com/DaAwesomeP","followers_url":"https://api.github.com/users/DaAwesomeP/followers","following_url":"https://api.github.com/users/DaAwesomeP/following{/other_user}","gists_url":"https://api.github.com/users/DaAwesomeP/gists{/gist_id}","starred_url":"https://api.github.com/users/DaAwesomeP/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DaAwesomeP/subscriptions","organizations_url":"https://api.github.com/users/DaAwesomeP/orgs","repos_url":"https://api.github.com/users/DaAwesomeP/repos","events_url":"https://api.github.com/users/DaAwesomeP/events{/privacy}","received_events_url":"https://api.github.com/users/DaAwesomeP/received_events","type":"User","site_admin":false},"body":"This pull:\r\n - New tests, 100% coverage (if you enable Coveralls)\r\n - Update to new `node_redis` version\r\n - Update other dependencies, remove `supertest` and `blanket`\r\n - Add support for all options in `node_redis` while keeping backward compatibility\r\n - Add support for the `duplicate` option\r\n - Add support for `quit()` and `end()` from the object\r\n - Add lots of details in docs (README)\r\n - Adds `hiredis` as an optional dependency (faster parser). Because it is optional, if it fails to build it will not cause any harm (it will use the JS parser as it was before). This is why Travis now has GCC.\r\n\r\n@dead-horse I did not update the benchmarks, which most certainly have changed. It would also be nice if you could release a new version `v1.1.0` with this. This is backwards compatible with previous versions (see [lines 41-42](https://github.com/DaAwesomeP/koa-redis/blob/32a120f6886b9a5ae6661932c5e7a2d13cb04434/index.js#L41-L42), [71](https://github.com/DaAwesomeP/koa-redis/blob/32a120f6886b9a5ae6661932c5e7a2d13cb04434/index.js#L71)) despite the new way that options are passed to `node_redis`.\r\n\r\nThis squashes #12 (sorry @JacksonTian).","created_at":"2016-01-08T01:06:13Z","updated_at":"2016-01-08T03:22:01Z","closed_at":null,"merged_at":null,"merge_commit_sha":"1ec943fffa9d41f2aad70176ae66eb4fe1233eb5","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/koajs/koa-redis/pulls/13/commits","review_comments_url":"https://api.github.com/repos/koajs/koa-redis/pulls/13/comments","review_comment_url":"https://api.github.com/repos/koajs/koa-redis/pulls/comments{/number}","comments_url":"https://api.github.com/repos/koajs/koa-redis/issues/13/comments","statuses_url":"https://api.github.com/repos/koajs/koa-redis/statuses/a64752f72381b4a9a6d0a404c8969bf3bc39c6b2","head":{"label":"DaAwesomeP:master","ref":"master","sha":"a64752f72381b4a9a6d0a404c8969bf3bc39c6b2","user":{"login":"DaAwesomeP","id":4472083,"avatar_url":"https://avatars.githubusercontent.com/u/4472083?v=3","gravatar_id":"","url":"https://api.github.com/users/DaAwesomeP","html_url":"https://github.com/DaAwesomeP","followers_url":"https://api.github.com/users/DaAwesomeP/followers","following_url":"https://api.github.com/users/DaAwesomeP/following{/other_user}","gists_url":"https://api.github.com/users/DaAwesomeP/gists{/gist_id}","starred_url":"https://api.github.com/users/DaAwesomeP/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DaAwesomeP/subscriptions","organizations_url":"https://api.github.com/users/DaAwesomeP/orgs","repos_url":"https://api.github.com/users/DaAwesomeP/repos","events_url":"https://api.github.com/users/DaAwesomeP/events{/privacy}","received_events_url":"https://api.github.com/users/DaAwesomeP/received_events","type":"User","site_admin":false},"repo":{"id":49034864,"name":"koa-redis","full_name":"DaAwesomeP/koa-redis","owner":{"login":"DaAwesomeP","id":4472083,"avatar_url":"https://avatars.githubusercontent.com/u/4472083?v=3","gravatar_id":"","url":"https://api.github.com/users/DaAwesomeP","html_url":"https://github.com/DaAwesomeP","followers_url":"https://api.github.com/users/DaAwesomeP/followers","following_url":"https://api.github.com/users/DaAwesomeP/following{/other_user}","gists_url":"https://api.github.com/users/DaAwesomeP/gists{/gist_id}","starred_url":"https://api.github.com/users/DaAwesomeP/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DaAwesomeP/subscriptions","organizations_url":"https://api.github.com/users/DaAwesomeP/orgs","repos_url":"https://api.github.com/users/DaAwesomeP/repos","events_url":"https://api.github.com/users/DaAwesomeP/events{/privacy}","received_events_url":"https://api.github.com/users/DaAwesomeP/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/DaAwesomeP/koa-redis","description":"koa session with redis","fork":true,"url":"https://api.github.com/repos/DaAwesomeP/koa-redis","forks_url":"https://api.github.com/repos/DaAwesomeP/koa-redis/forks","keys_url":"https://api.github.com/repos/DaAwesomeP/koa-redis/keys{/key_id}","collaborators_url":"https://api.github.com/repos/DaAwesomeP/koa-redis/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/DaAwesomeP/koa-redis/teams","hooks_url":"https://api.github.com/repos/DaAwesomeP/koa-redis/hooks","issue_events_url":"https://api.github.com/repos/DaAwesomeP/koa-redis/issues/events{/number}","events_url":"https://api.github.com/repos/DaAwesomeP/koa-redis/events","assignees_url":"https://api.github.com/repos/DaAwesomeP/koa-redis/assignees{/user}","branches_url":"https://api.github.com/repos/DaAwesomeP/koa-redis/branches{/branch}","tags_url":"https://api.github.com/repos/DaAwesomeP/koa-redis/tags","blobs_url":"https://api.github.com/repos/DaAwesomeP/koa-redis/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/DaAwesomeP/koa-redis/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/DaAwesomeP/koa-redis/git/refs{/sha}","trees_url":"https://api.github.com/repos/DaAwesomeP/koa-redis/git/trees{/sha}","statuses_url":"https://api.github.com/repos/DaAwesomeP/koa-redis/statuses/{sha}","languages_url":"https://api.github.com/repos/DaAwesomeP/koa-redis/languages","stargazers_url":"https://api.github.com/repos/DaAwesomeP/koa-redis/stargazers","contributors_url":"https://api.github.com/repos/DaAwesomeP/koa-redis/contributors","subscribers_url":"https://api.github.com/repos/DaAwesomeP/koa-redis/subscribers","subscription_url":"https://api.github.com/repos/DaAwesomeP/koa-redis/subscription","commits_url":"https://api.github.com/repos/DaAwesomeP/koa-redis/commits{/sha}","git_commits_url":"https://api.github.com/repos/DaAwesomeP/koa-redis/git/commits{/sha}","comments_url":"https://api.github.com/repos/DaAwesomeP/koa-redis/comments{/number}","issue_comment_url":"https://api.github.com/repos/DaAwesomeP/koa-redis/issues/comments{/number}","contents_url":"https://api.github.com/repos/DaAwesomeP/koa-redis/contents/{+path}","compare_url":"https://api.github.com/repos/DaAwesomeP/koa-redis/compare/{base}...{head}","merges_url":"https://api.github.com/repos/DaAwesomeP/koa-redis/merges","archive_url":"https://api.github.com/repos/DaAwesomeP/koa-redis/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/DaAwesomeP/koa-redis/downloads","issues_url":"https://api.github.com/repos/DaAwesomeP/koa-redis/issues{/number}","pulls_url":"https://api.github.com/repos/DaAwesomeP/koa-redis/pulls{/number}","milestones_url":"https://api.github.com/repos/DaAwesomeP/koa-redis/milestones{/number}","notifications_url":"https://api.github.com/repos/DaAwesomeP/koa-redis/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/DaAwesomeP/koa-redis/labels{/name}","releases_url":"https://api.github.com/repos/DaAwesomeP/koa-redis/releases{/id}","created_at":"2016-01-05T01:49:00Z","updated_at":"2016-01-05T01:49:00Z","pushed_at":"2016-01-08T03:19:50Z","git_url":"git://github.com/DaAwesomeP/koa-redis.git","ssh_url":"git@github.com:DaAwesomeP/koa-redis.git","clone_url":"https://github.com/DaAwesomeP/koa-redis.git","svn_url":"https://github.com/DaAwesomeP/koa-redis","homepage":null,"size":41,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"koajs:master","ref":"master","sha":"0cbb77edc0f97b9eb40bb3cc350d5b73e2e09fcc","user":{"login":"koajs","id":5055057,"avatar_url":"https://avatars.githubusercontent.com/u/5055057?v=3","gravatar_id":"","url":"https://api.github.com/users/koajs","html_url":"https://github.com/koajs","followers_url":"https://api.github.com/users/koajs/followers","following_url":"https://api.github.com/users/koajs/following{/other_user}","gists_url":"https://api.github.com/users/koajs/gists{/gist_id}","starred_url":"https://api.github.com/users/koajs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/koajs/subscriptions","organizations_url":"https://api.github.com/users/koajs/orgs","repos_url":"https://api.github.com/users/koajs/repos","events_url":"https://api.github.com/users/koajs/events{/privacy}","received_events_url":"https://api.github.com/users/koajs/received_events","type":"Organization","site_admin":false},"repo":{"id":15478900,"name":"koa-redis","full_name":"koajs/koa-redis","owner":{"login":"koajs","id":5055057,"avatar_url":"https://avatars.githubusercontent.com/u/5055057?v=3","gravatar_id":"","url":"https://api.github.com/users/koajs","html_url":"https://github.com/koajs","followers_url":"https://api.github.com/users/koajs/followers","following_url":"https://api.github.com/users/koajs/following{/other_user}","gists_url":"https://api.github.com/users/koajs/gists{/gist_id}","starred_url":"https://api.github.com/users/koajs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/koajs/subscriptions","organizations_url":"https://api.github.com/users/koajs/orgs","repos_url":"https://api.github.com/users/koajs/repos","events_url":"https://api.github.com/users/koajs/events{/privacy}","received_events_url":"https://api.github.com/users/koajs/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/koajs/koa-redis","description":"koa session with redis","fork":false,"url":"https://api.github.com/repos/koajs/koa-redis","forks_url":"https://api.github.com/repos/koajs/koa-redis/forks","keys_url":"https://api.github.com/repos/koajs/koa-redis/keys{/key_id}","collaborators_url":"https://api.github.com/repos/koajs/koa-redis/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/koajs/koa-redis/teams","hooks_url":"https://api.github.com/repos/koajs/koa-redis/hooks","issue_events_url":"https://api.github.com/repos/koajs/koa-redis/issues/events{/number}","events_url":"https://api.github.com/repos/koajs/koa-redis/events","assignees_url":"https://api.github.com/repos/koajs/koa-redis/assignees{/user}","branches_url":"https://api.github.com/repos/koajs/koa-redis/branches{/branch}","tags_url":"https://api.github.com/repos/koajs/koa-redis/tags","blobs_url":"https://api.github.com/repos/koajs/koa-redis/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/koajs/koa-redis/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/koajs/koa-redis/git/refs{/sha}","trees_url":"https://api.github.com/repos/koajs/koa-redis/git/trees{/sha}","statuses_url":"https://api.github.com/repos/koajs/koa-redis/statuses/{sha}","languages_url":"https://api.github.com/repos/koajs/koa-redis/languages","stargazers_url":"https://api.github.com/repos/koajs/koa-redis/stargazers","contributors_url":"https://api.github.com/repos/koajs/koa-redis/contributors","subscribers_url":"https://api.github.com/repos/koajs/koa-redis/subscribers","subscription_url":"https://api.github.com/repos/koajs/koa-redis/subscription","commits_url":"https://api.github.com/repos/koajs/koa-redis/commits{/sha}","git_commits_url":"https://api.github.com/repos/koajs/koa-redis/git/commits{/sha}","comments_url":"https://api.github.com/repos/koajs/koa-redis/comments{/number}","issue_comment_url":"https://api.github.com/repos/koajs/koa-redis/issues/comments{/number}","contents_url":"https://api.github.com/repos/koajs/koa-redis/contents/{+path}","compare_url":"https://api.github.com/repos/koajs/koa-redis/compare/{base}...{head}","merges_url":"https://api.github.com/repos/koajs/koa-redis/merges","archive_url":"https://api.github.com/repos/koajs/koa-redis/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/koajs/koa-redis/downloads","issues_url":"https://api.github.com/repos/koajs/koa-redis/issues{/number}","pulls_url":"https://api.github.com/repos/koajs/koa-redis/pulls{/number}","milestones_url":"https://api.github.com/repos/koajs/koa-redis/milestones{/number}","notifications_url":"https://api.github.com/repos/koajs/koa-redis/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/koajs/koa-redis/labels{/name}","releases_url":"https://api.github.com/repos/koajs/koa-redis/releases{/id}","created_at":"2013-12-27T17:50:49Z","updated_at":"2016-01-08T02:24:35Z","pushed_at":"2016-01-08T03:19:50Z","git_url":"git://github.com/koajs/koa-redis.git","ssh_url":"git@github.com:koajs/koa-redis.git","clone_url":"https://github.com/koajs/koa-redis.git","svn_url":"https://github.com/koajs/koa-redis","homepage":null,"size":34,"stargazers_count":50,"watchers_count":50,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":8,"mirror_url":null,"open_issues_count":4,"forks":8,"open_issues":4,"watchers":50,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/koajs/koa-redis/pulls/13"},"html":{"href":"https://github.com/koajs/koa-redis/pull/13"},"issue":{"href":"https://api.github.com/repos/koajs/koa-redis/issues/13"},"comments":{"href":"https://api.github.com/repos/koajs/koa-redis/issues/13/comments"},"review_comments":{"href":"https://api.github.com/repos/koajs/koa-redis/pulls/13/comments"},"review_comment":{"href":"https://api.github.com/repos/koajs/koa-redis/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/koajs/koa-redis/pulls/13/commits"},"statuses":{"href":"https://api.github.com/repos/koajs/koa-redis/statuses/a64752f72381b4a9a6d0a404c8969bf3bc39c6b2"}}}}