add TRITON_TEST_PROFILE and TRITON_TEST_DESTRUCTIVE_ALLOWED

This commit is contained in:
Dave Eddy 2015-10-01 12:27:05 -04:00
parent b9df8e6693
commit 3ba8f312f1

View File

@ -17,40 +17,54 @@ var assert = require('assert-plus');
var f = require('util').format; var f = require('util').format;
var path = require('path'); var path = require('path');
var testcommon = require('../lib/testcommon'); var mod_config = require('../../lib/config');
var testcommon = require('../lib/testcommon');
// --- globals // --- globals
try { var CONFIG;
var CONFIG = require('../config.json'); if (process.env.TRITON_TEST_PROFILE) {
assert.object(CONFIG, 'test/config.json'); CONFIG = mod_config.loadProfile({
assert.string(CONFIG.url, 'test/config.json#url'); configDir: path.join(process.env.HOME, '.triton'),
assert.string(CONFIG.account, 'test/config.json#account'); name: process.env.TRITON_TEST_PROFILE
assert.string(CONFIG.keyId, 'test/config.json#keyId'); });
if (CONFIG.insecure === undefined) CONFIG.destructiveAllowed = !!process.env.TRITON_TEST_DESTRUCTIVE_ALLOWED;
CONFIG.insecure = false; } else {
if (CONFIG.destructiveAllowed === undefined) CONFIG = require('../config.json');
CONFIG.destructiveAllowed = false; try {
assert.bool(CONFIG.insecure, 'test/config.json#destructiveAllowed'); assert.object(CONFIG, 'test/config.json');
} catch (e) { assert.string(CONFIG.url, 'test/config.json#url');
error('* * *'); assert.string(CONFIG.account, 'test/config.json#account');
error('node-triton integration tests require a ./test/config.json'); assert.string(CONFIG.keyId, 'test/config.json#keyId');
error(''); assert.optionalBool(CONFIG.insecure,
error(' {'); 'test/config.json#insecure');
error(' "url": "<CloudAPI URL>",'); assert.optionalBool(CONFIG.destrectiveAllowed,
error(' "account": "<account>",'); 'test/config.json#destructiveAllowed');
error(' "keyId": "<ssh key fingerprint>",'); } catch (e) {
error(' "insecure": true|false, // optional'); error('* * *');
error(' "destructiveAllowed": true|false // optional'); error('node-triton integration tests require a ./test/config.json');
error(' }'); error('or TRITON_TEST_PROFILE to be set to a profile');
error(''); error('');
error('Note: This test suite with create machines, images, et al using'); error(' {');
error('this CloudAPI and account. That could *cost* you money. :)'); error(' "url": "<CloudAPI URL>",');
error('* * *'); error(' "account": "<account>",');
throw e; error(' "keyId": "<ssh key fingerprint>",');
error(' "insecure": true|false, // optional');
error(' "destructiveAllowed": true|false // optional');
error(' }');
error('');
error('Note: This test suite with create machines, images, etc. using');
error('this CloudAPI and account. That could *cost* you money. :)');
error('* * *');
throw e;
}
} }
if (CONFIG.insecure === undefined)
CONFIG.insecure = false;
if (CONFIG.destructiveAllowed === undefined)
CONFIG.destructiveAllowed = false;
var TRITON = [process.execPath, path.resolve(__dirname, '../../bin/triton')]; var TRITON = [process.execPath, path.resolve(__dirname, '../../bin/triton')];
var UA = 'node-triton-test'; var UA = 'node-triton-test';