Skip to content
Browse files

add more method

  • Loading branch information...
1 parent b921713 commit 40eb8e2ac44c6eb10dd19755b661540f63367fb9 @dead-horse dead-horse committed Apr 13, 2012
View
10 Makefile
@@ -6,4 +6,12 @@ test:
@NODE_ENV=test ./node_modules/mocha/bin/mocha \
--reporter $(REPORTER) --timeout $(TESTTIMEOUT) $(TEST)
-.PHONY: test
+test-cov:
+ @JSCOV=1 NODE_ENV=test ./node_modules/mocha/bin/mocha \
+ --reporter html-cov --timeout $(TESTTIMEOUT) $(TEST) > coverage.html
+
+clean:
+ @rm -rf *-cov
+ @rm -f coverage.html
+
+.PHONY: test test-cov clean
View
4 lib/multi_redis.js
@@ -131,12 +131,12 @@ util.inherits(MultiRedis, EventEmitter);
* redis get like commands
* @type {Array}
*/
-var getCmds = ['get', 'mget', 'exists', 'getbit', 'hget', 'hmget', 'info'];
+var getCmds = ['get', 'mget', 'exists', 'getbit', 'hget', 'hmget', 'info', 'hgetall'];
/**
* redis set like commands
* @type {Array}
*/
-var setCmds = ['set', 'setnx', 'setex', 'append', 'del', 'hset', 'hmset', 'auth', 'select'];
+var setCmds = ['set', 'setnx', 'setex', 'append', 'del', 'hset', 'hmset', 'auth', 'select', 'incr', 'decr', 'hincrby', 'expire'];
/**
* change arguments to array
View
49 test/helper/ensure_require.js
@@ -0,0 +1,49 @@
+/*!
+ * tcif - test/support/ensure_require.js, Ensure coverage require.
+ * Copyright(c) 2012 fengmk2 <fengmk2@gmail.com>
+ * MIT Licensed
+ */
+
+/**
+ * Module dependencies.
+ */
+
+var fs = require('fs');
+var path = require('path');
+var require = require('jscoverage').require(module);
+var isCov = process.env.JSCOV === '1';
+
+var APPDIR = path.dirname(path.dirname(__dirname));
+
+var libs = [
+ 'lib'
+];
+
+requireFirst(libs, isCov);
+
+function requireFirst(names, cov) {
+ for (var i = 0, l = names.length; i < l; i++) {
+ var dirpath = path.join(APPDIR, names[i]);
+ if (dirpath.indexOf('.js') > 0) {
+ require(dirpath, cov);
+ continue;
+ }
+ requireDir(dirpath, cov);
+ }
+}
+
+function requireDir(dirpath, cov) {
+ var names = fs.readdirSync(dirpath);
+ for (var j = 0, jl = names.length; j < jl; j++) {
+ var name = names[j];
+ if (name[0] === '.') {
+ continue;
+ }
+ var filepath = path.join(dirpath, name);
+ if (fs.statSync(filepath).isDirectory()) {
+ requireDir(filepath);
+ } else if (path.extname(filepath) === '.js') {
+ require(filepath, cov);
+ }
+ }
+}
View
2 test/mocha.opts
@@ -1,3 +1,3 @@
--require node_modules/should
--require assert
---growl
+--growl
View
3 test/multi_redis_functional_test.js
@@ -1,3 +1,4 @@
+require('./helper/ensure_require');
var multiRedis = require('../lib/multi_redis');
/**
@@ -89,4 +90,4 @@ describe('functional test', function() {
})
})
-})
+})
View
3 test/multi_redis_stability_test.js
@@ -1,3 +1,4 @@
+require('./helper/ensure_require');
var multiRedis = require('../lib/multi_redis');
/**
@@ -90,4 +91,4 @@ describe('multi redis statbility test', function() {
})
})
})
-})
+})

0 comments on commit 40eb8e2

Please sign in to comment.
Something went wrong with that request. Please try again.