diff --git a/package.json b/package.json index 9ac21f8..a777af2 100644 --- a/package.json +++ b/package.json @@ -18,7 +18,7 @@ "scripts": { "start": "./node_modules/.bin/coffee app.coffee", "migrate": "./node_modules/.bin/coffee migration/migrate.coffee", - "test": "COV_TEST=true ./node_modules/.bin/mocha --compilers coffee:coffee-script/register --require test/env --reporter test/reporter-cov-summary.js -- core/test/*.test.coffee core/test/*/*.test.coffee plugin/*/test", + "test": "COV_TEST=true ./node_modules/.bin/mocha --compilers coffee:coffee-script/register --require test/env --reporter node_modules/mocha-reporter-cov-summary -- core/test/*.test.coffee core/test/*/*.test.coffee plugin/*/test", "test-only": "./node_modules/.bin/mocha --compilers coffee:coffee-script/register --require test/env -- core/test/*.test.coffee core/test/*/*.test.coffee plugin/*/test", "test-full": "./node_modules/.bin/coffee test/full-test.coffee", "test-cov-html": "COV_TEST=true ./node_modules/.bin/mocha --compilers coffee:coffee-script/register --require test/env --reporter html-cov -- core/test/*.test.coffee core/test/*/*.test.coffee plugin/*/test > coverage-reporter.html" @@ -65,6 +65,7 @@ "mocha": "^2.0.0", "chai": "^1.9.2", "coffee-coverage": "^0.4.2", - "supertest": "^0.14.0" + "supertest": "^0.14.0", + "mocha-reporter-cov-summary": "^0.1.0" } } diff --git a/plugin/linux/linux.coffee b/plugin/linux/linux.coffee index 09faa7f..40a62e4 100644 --- a/plugin/linux/linux.coffee +++ b/plugin/linux/linux.coffee @@ -45,7 +45,7 @@ exports.setResourceLimit = (account, callback) -> child_process.exec "sudo setquota -u #{account.username} #{soft_limit} #{hard_limit} #{soft_inode_limit} #{hard_inode_limit} -a", (err) -> logger.error err if err - callback() + cache.delete 'linux.getStorageQuota', callback exports.getPasswdMap = (callback) -> cache.try 'linux.getPasswdMap', (SETEX) -> diff --git a/plugin/linux/test/linux.test.coffee b/plugin/linux/test/linux.test.coffee index fcd9acc..8c47b21 100644 --- a/plugin/linux/test/linux.test.coffee +++ b/plugin/linux/test/linux.test.coffee @@ -26,15 +26,24 @@ describe 'plugin/linux', -> fs.existsSync("/home/#{username}").should.be.ok done() + describe 'setResourceLimit', -> + it 'should success', (done) -> + account = + username: username + billing: + services: ['linux'] + resources_limit: + storage: 300 + + linux.setResourceLimit account, -> + done() + describe 'deleteUser', -> it 'should success', (done) -> linux.deleteUser {username: username}, -> expect(fs.existsSync("/home/#{username}")).to.not.ok done() - describe 'setResourceLimit', -> - it 'pending' - describe 'getPasswdMap', -> before (done) -> cache.delete 'linux.getPasswdMap', done diff --git a/test/full-test.coffee b/test/full-test.coffee index d475fc6..a26cc0d 100644 --- a/test/full-test.coffee +++ b/test/full-test.coffee @@ -8,7 +8,7 @@ async.eachSeries fs.readdirSync("#{__dirname}/../sample"), (filename, callback) console.log "Config: #{filename}" - params = '--compilers coffee:coffee-script/register --require test/env --reporter test/reporter-cov-summary.js -- + params = '--compilers coffee:coffee-script/register --require test/env --reporter node_modules/mocha-reporter-cov-summary -- core/test/*.test.coffee core/test/*/*.test.coffee'.split(' ') config = require "#{__dirname}/../sample/#{filename}" diff --git a/test/reporter-cov-summary.js b/test/reporter-cov-summary.js deleted file mode 100644 index 36e0279..0000000 --- a/test/reporter-cov-summary.js +++ /dev/null @@ -1,38 +0,0 @@ -var fs = require('fs'); -var util = require ('util'); - -var Spec = require('mocha/lib/reporters/spec'); - -exports = module.exports = CovSummary; - -function CovSummary(runner) { - Spec.call(this, runner); - - runner.on('end', report); -} - -function report() { - var cov = global._$jscoverage || {}; - var files = Object.keys(cov); - - var covered_lines = 0; - var total_lines = 0; - - files.forEach(function(file) { - cov[file].forEach(function(line) { - if(line !== undefined) { - total_lines ++; - - if (line !== 0) { - covered_lines ++; - } - } - }); - }); - - var covered = (covered_lines / total_lines * 100).toFixed(1); - - console.log(util.format('Coverage Summary: %s lines of %s lines, %s% covered \n', covered_lines, total_lines, covered)); -} - -CovSummary.prototype.__proto__ = Spec.prototype;