'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:
parent
a26164f01f
commit
a67341b1b0
5
Makefile
5
Makefile
@ -25,7 +25,10 @@ all:
|
||||
npm install
|
||||
|
||||
.PHONY: test
|
||||
test:
|
||||
test: test-unit test-integration
|
||||
|
||||
.PHONY: test-unit
|
||||
test-unit:
|
||||
NODE_NDEBUG= ./node_modules/.bin/tape test/unit/*.test.js
|
||||
|
||||
.PHONY: test-integration
|
||||
|
36
README.md
36
README.md
@ -252,16 +252,48 @@ differences and backward incompatibilities are discussed here.
|
||||
|
||||
## Development Hooks
|
||||
|
||||
Before commiting be sure to:
|
||||
Before commiting be sure to, at least:
|
||||
|
||||
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
|
||||
clone via:
|
||||
|
||||
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
|
||||
|
||||
MPL 2.0
|
||||
|
@ -17,8 +17,8 @@ var assert = require('assert-plus');
|
||||
var f = require('util').format;
|
||||
var path = require('path');
|
||||
|
||||
var common = require('../../lib/common');
|
||||
var mod_config = require('../../lib/config');
|
||||
|
||||
var testcommon = require('../lib/testcommon');
|
||||
|
||||
|
||||
@ -30,7 +30,8 @@ if (process.env.TRITON_TEST_PROFILE) {
|
||||
configDir: path.join(process.env.HOME, '.triton'),
|
||||
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 {
|
||||
try {
|
||||
CONFIG = require('../config.json');
|
||||
@ -40,12 +41,18 @@ if (process.env.TRITON_TEST_PROFILE) {
|
||||
assert.string(CONFIG.keyId, 'test/config.json#keyId');
|
||||
assert.optionalBool(CONFIG.insecure,
|
||||
'test/config.json#insecure');
|
||||
assert.optionalBool(CONFIG.destrectiveAllowed,
|
||||
assert.optionalBool(CONFIG.destructiveAllowed,
|
||||
'test/config.json#destructiveAllowed');
|
||||
} catch (e) {
|
||||
error('* * *');
|
||||
error('node-triton integration tests require a ./test/config.json');
|
||||
error('or TRITON_TEST_PROFILE to be set to a profile');
|
||||
error('node-triton integration tests require either:');
|
||||
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(' "url": "<CloudAPI URL>",');
|
||||
@ -55,8 +62,10 @@ if (process.env.TRITON_TEST_PROFILE) {
|
||||
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('Note: This test suite will create machines, images, etc. ');
|
||||
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('* * *');
|
||||
throw e;
|
||||
}
|
||||
|
@ -19,4 +19,4 @@ set -o errexit
|
||||
set -o pipefail
|
||||
|
||||
make check
|
||||
make test
|
||||
make test-unit
|
||||
|
Reference in New Issue
Block a user