'make test' now runs unit and integration tests.

'make test-unit' just the unit tests (pre-commit updated to just the latter
Fix one typo in destructiveAllowed.
This commit is contained in:
Trent Mick 2015-10-05 07:31:45 -07:00
parent a26164f01f
commit a67341b1b0
4 changed files with 55 additions and 11 deletions

View File

@ -25,7 +25,10 @@ all:
npm install npm install
.PHONY: test .PHONY: test
test: test: test-unit test-integration
.PHONY: test-unit
test-unit:
NODE_NDEBUG= ./node_modules/.bin/tape test/unit/*.test.js NODE_NDEBUG= ./node_modules/.bin/tape test/unit/*.test.js
.PHONY: test-integration .PHONY: test-integration

View File

@ -252,16 +252,48 @@ differences and backward incompatibilities are discussed here.
## Development Hooks ## Development Hooks
Before commiting be sure to: Before commiting be sure to, at least:
make check # lint and style checks make check # lint and style checks
make test # run unit tests make test-unit # run unit tests
A good way to do that is to install the stock pre-commit hook in your A good way to do that is to install the stock pre-commit hook in your
clone via: clone via:
make git-hooks make git-hooks
Also please run the full (longer) test suite (`make test`). See the next
section.
## Test suite
node-triton has both unit tests (`make test-unit`) and integration tests (`make
test-integration`). Integration tests require either:
1. environment variables like:
TRITON_TEST_PROFILE=<Triton profile name>
TRITON_TEST_DESTRUCTIVE_ALLOWED=1 # Optional
2. or, a "./test/config.json" like this:
{
"url": "<CloudAPI URL>",
"account": "<account>",
"keyId": "<ssh key fingerprint>",
"insecure": true|false, // optional
"destructiveAllowed": true|false // optional
}
For example, a possible run could be:
TRITON_TEST_PROFILE=coal TRITON_TEST_DESTRUCTIVE_ALLOWED=1 make test
Where "coal" here refers to a development Triton (a.k.a SDC) ["Cloud On A
Laptop"](https://github.com/joyent/sdc#getting-started).
## License ## License
MPL 2.0 MPL 2.0

View File

@ -17,8 +17,8 @@ var assert = require('assert-plus');
var f = require('util').format; var f = require('util').format;
var path = require('path'); var path = require('path');
var common = require('../../lib/common');
var mod_config = require('../../lib/config'); var mod_config = require('../../lib/config');
var testcommon = require('../lib/testcommon'); var testcommon = require('../lib/testcommon');
@ -30,7 +30,8 @@ if (process.env.TRITON_TEST_PROFILE) {
configDir: path.join(process.env.HOME, '.triton'), configDir: path.join(process.env.HOME, '.triton'),
name: process.env.TRITON_TEST_PROFILE name: process.env.TRITON_TEST_PROFILE
}); });
CONFIG.destructiveAllowed = !!process.env.TRITON_TEST_DESTRUCTIVE_ALLOWED; CONFIG.destructiveAllowed = common.boolFromString(
process.env.TRITON_TEST_DESTRUCTIVE_ALLOWED);
} else { } else {
try { try {
CONFIG = require('../config.json'); CONFIG = require('../config.json');
@ -40,12 +41,18 @@ if (process.env.TRITON_TEST_PROFILE) {
assert.string(CONFIG.keyId, 'test/config.json#keyId'); assert.string(CONFIG.keyId, 'test/config.json#keyId');
assert.optionalBool(CONFIG.insecure, assert.optionalBool(CONFIG.insecure,
'test/config.json#insecure'); 'test/config.json#insecure');
assert.optionalBool(CONFIG.destrectiveAllowed, assert.optionalBool(CONFIG.destructiveAllowed,
'test/config.json#destructiveAllowed'); '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 either:');
error('or TRITON_TEST_PROFILE to be set to a profile'); error('');
error('1. environment variables like:');
error('');
error(' TRITON_TEST_PROFILE=<Triton profile name>');
error(' TRITON_TEST_DESTRUCTIVE_ALLOWED=1 # Optional');
error('');
error('2. or, a "./test/config.json" like this:');
error(''); error('');
error(' {'); error(' {');
error(' "url": "<CloudAPI URL>",'); error(' "url": "<CloudAPI URL>",');
@ -55,8 +62,10 @@ if (process.env.TRITON_TEST_PROFILE) {
error(' "destructiveAllowed": true|false // optional'); error(' "destructiveAllowed": true|false // optional');
error(' }'); error(' }');
error(''); error('');
error('Note: This test suite with create machines, images, etc. using'); error('Note: This test suite will create machines, images, etc. ');
error('this CloudAPI and account. That could *cost* you money. :)'); error('using this CloudAPI and account. While it will do its best');
error('to clean up all resources, running the test suite against');
error('a public cloud could *cost* you money. :)');
error('* * *'); error('* * *');
throw e; throw e;
} }

View File

@ -19,4 +19,4 @@ set -o errexit
set -o pipefail set -o pipefail
make check make check
make test make test-unit