add TRITON_TEST_PROFILE and TRITON_TEST_DESTRUCTIVE_ALLOWED
This commit is contained in:
parent
b9df8e6693
commit
3ba8f312f1
@ -17,26 +17,35 @@ 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) {
|
||||||
|
CONFIG = mod_config.loadProfile({
|
||||||
|
configDir: path.join(process.env.HOME, '.triton'),
|
||||||
|
name: process.env.TRITON_TEST_PROFILE
|
||||||
|
});
|
||||||
|
CONFIG.destructiveAllowed = !!process.env.TRITON_TEST_DESTRUCTIVE_ALLOWED;
|
||||||
|
} else {
|
||||||
|
CONFIG = require('../config.json');
|
||||||
|
try {
|
||||||
assert.object(CONFIG, 'test/config.json');
|
assert.object(CONFIG, 'test/config.json');
|
||||||
assert.string(CONFIG.url, 'test/config.json#url');
|
assert.string(CONFIG.url, 'test/config.json#url');
|
||||||
assert.string(CONFIG.account, 'test/config.json#account');
|
assert.string(CONFIG.account, 'test/config.json#account');
|
||||||
assert.string(CONFIG.keyId, 'test/config.json#keyId');
|
assert.string(CONFIG.keyId, 'test/config.json#keyId');
|
||||||
if (CONFIG.insecure === undefined)
|
assert.optionalBool(CONFIG.insecure,
|
||||||
CONFIG.insecure = false;
|
'test/config.json#insecure');
|
||||||
if (CONFIG.destructiveAllowed === undefined)
|
assert.optionalBool(CONFIG.destrectiveAllowed,
|
||||||
CONFIG.destructiveAllowed = false;
|
'test/config.json#destructiveAllowed');
|
||||||
assert.bool(CONFIG.insecure, 'test/config.json#destructiveAllowed');
|
} catch (e) {
|
||||||
} catch (e) {
|
|
||||||
error('* * *');
|
error('* * *');
|
||||||
error('node-triton integration tests require a ./test/config.json');
|
error('node-triton integration tests require a ./test/config.json');
|
||||||
|
error('or TRITON_TEST_PROFILE to be set to a profile');
|
||||||
error('');
|
error('');
|
||||||
error(' {');
|
error(' {');
|
||||||
error(' "url": "<CloudAPI URL>",');
|
error(' "url": "<CloudAPI URL>",');
|
||||||
@ -46,11 +55,16 @@ try {
|
|||||||
error(' "destructiveAllowed": true|false // optional');
|
error(' "destructiveAllowed": true|false // optional');
|
||||||
error(' }');
|
error(' }');
|
||||||
error('');
|
error('');
|
||||||
error('Note: This test suite with create machines, images, et al using');
|
error('Note: This test suite with create machines, images, etc. using');
|
||||||
error('this CloudAPI and account. That could *cost* you money. :)');
|
error('this CloudAPI and account. That could *cost* you money. :)');
|
||||||
error('* * *');
|
error('* * *');
|
||||||
throw e;
|
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';
|
||||||
|
Reference in New Issue
Block a user