full test script

This commit is contained in:
jysperm
2014-11-01 00:32:31 +08:00
parent 5b33667a00
commit ed17eeb232
9 changed files with 47 additions and 86 deletions

View File

@@ -4,6 +4,8 @@ node_js:
- 0.11
- 0.10
script: npm run test-full
services:
- mongodb
- redis-server

View File

@@ -48,22 +48,13 @@ do ->
config_path = path.join __dirname, 'config.coffee'
unless fs.existsSync config_path
unless process.env.TRAVIS == 'true'
app.deprecate 'config.coffee not found, copy sample config to ./config.coffee'
default_config = 'core'
else
default_config = 'travis-ci'
fs.writeFileSync config_path, fs.readFileSync path.join __dirname, "./sample/#{default_config}.config.coffee"
app.deprecate 'config.coffee not found, copy sample config to ./config.coffee'
fs.writeFileSync config_path, fs.readFileSync path.join __dirname, "./sample/core.config.coffee"
fs.chmodSync config_path, 0o750
config = require './config'
if process.env.NODE_ENV == 'test'
config.web.listen = require('./sample/travis-ci.config').web.listen
do ->
if fs.existsSync config.web.listen
fs.unlinkSync config.web.listen

View File

@@ -48,7 +48,7 @@ describe 'billing', ->
expect(billing.isForceFreeze(account)).to.not.ok
it 'should be true when balance below then 0', ->
account.billing.plans = ['sample']
account.billing.plans = ['billing_test']
account.billing.balance = -5
expect(billing.isForceFreeze(account)).to.be.ok

View File

@@ -18,9 +18,10 @@
"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/support/env --reporter test/support/reporter-cov-summary.js -- core/test/*.test.coffee core/test/*/*.test.coffee plugin/*/test",
"test-only": "./node_modules/.bin/mocha --compilers coffee:coffee-script/register --require test/support/env -- core/test/*.test.coffee core/test/*/*.test.coffee plugin/*/test",
"test-cov-html": "COV_TEST=true ./node_modules/.bin/mocha --compilers coffee:coffee-script/register --require test/support/env --reporter html-cov -- core/test/*.test.coffee core/test/*/*.test.coffee plugin/*/test > coverage-reporter.html"
"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-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"
},
"bin": {
"rp-fix-permissions": "./bin/rp-fix-permissions.coffee",

View File

@@ -14,8 +14,8 @@ module.exports =
default_timezone: 'Asia/Shanghai'
plugin:
available_extensions: ['rpvhost', 'bitcoin', 'wiki']
available_services: ['ssh', 'linux']
available_extensions: []
available_services: []
billing:
currency: 'CNY'

View File

@@ -1,69 +0,0 @@
module.exports =
web:
t_name: 'plugins.rpvhost.site_name'
url: 'http://rp.rpvhost.net'
listen: 12558
google_analytics_id: ''
account:
cookie_time: 30 * 24 * 3600 * 1000
i18n:
available_language: ['zh_CN', 'en']
default_language: 'zh_CN'
default_timezone: 'Asia/Shanghai'
plugin:
available_extensions: []
available_services: []
billing:
currency: 'CNY'
force_freeze:
when_balance_below: 0
when_arrears_above: 0
billing_cycle: 10 * 60 * 1000
plans:
sample:
t_name: 'plans.sample.name'
t_description: 'plans.sample.name.description'
billing_by_time:
unit: 24 * 3600 * 1000
price: 10 / 30
services: []
resources: {}
test:
t_name: 'plans.test.name'
t_description: 'plans.test.name.description'
billing_by_usage:
auto_leave: 7 * 24 * 3600 * 1000
services: []
resources: {}
mongodb:
host: 'localhost'
name: 'RootPanel'
redis:
host: '127.0.0.1'
port: 6379
prefix: 'RP'
email:
send_from: 'robot@rpvhost.net'
account:
service: 'Postmark'
auth:
user: 'postmark-api-token'
pass: 'postmark-api-token'
plugins: {}

View File

@@ -25,3 +25,12 @@ global.namespace = {}
chai.should()
chai.config.includeStack = true
config = require '../config'
config.web.listen = 12558
if process.env.TRAVIS == 'true'
config.mongodb.user = undefined
config.mongodb.password = undefined
config.redis.password = undefined

27
test/full-test.coffee Normal file
View File

@@ -0,0 +1,27 @@
child_process = require 'child_process'
async = require 'async'
fs = require 'fs'
_ = require 'underscore'
async.eachSeries fs.readdirSync("#{__dirname}/../sample"), (filename, callback) ->
fs.writeFileSync "#{__dirname}/../config.coffee", fs.readFileSync "#{__dirname}/../sample/#{filename}"
console.log "Config: #{filename}"
proc = child_process.spawn "#{__dirname}/../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'.split(' '),
env: _.extend process.env,
COV_TEST: 'true'
proc.stdout.pipe process.stdout
proc.stderr.pipe process.stderr
proc.on 'close', (code) ->
if code
process.exit code
else
callback()
, ->
process.exit 0