cloudron-e2e-test/common.js
2015-08-24 11:59:15 -07:00

42 lines
1.2 KiB
JavaScript

'use strict';
var path = require('path'),
safe = require('safetydance');
exports = module.exports = {
TESTAPP_ID: 'io.cloudron.testapp',
TESTAPP_VERSION : '1.0.3',
cloudronDomain: cloudronDomain,
verifyResponse: verifyResponse,
getOwner: getOwner,
stripeSecret: stripeSecret
};
var gNow = ((new Date()).getTime() / 1000).toFixed();
var gEcosystem = safe.require(path.join(__dirname, '../keys/ci/ecosystem-prod.json'));
function cloudronDomain(filename) {
return 't-' + path.basename(filename, '-test.js') + '-' + gNow + '.smartserver.io';
}
function verifyResponse(res, errorMessage) {
if (res.statusCode < 200 || res.statusCode > 299) {
console.log('Response error statusCode:%s error:%s body:%s', res.statusCode, res.error, res.body);
console.log(errorMessage.red);
process.exit(1);
}
}
function getOwner() {
return {
username: process.env.APPSTORE_USERNAME || gEcosystem.env.APPSTORE_USERNAME,
password: process.env.APPSTORE_PASSWORD || gEcosystem.env.APPSTORE_PASSWORD,
email: process.env.APPSTORE_EMAIL || gEcosystem.env.APPSTORE_EMAIL
};
}
function stripeSecret() {
return process.env.STRIPE_SECRET || gEcosystem.env.STRIPE_SECRET;
}