some test of linux

This commit is contained in:
jysperm
2014-11-03 17:47:08 +08:00
parent 0db4f82757
commit e8e48f1918
5 changed files with 17 additions and 45 deletions

View File

@@ -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"
}
}

View File

@@ -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) ->

View File

@@ -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

View File

@@ -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}"

View File

@@ -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;