Skip to content

Commit

Permalink
fix tests and add cover
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexandre Tiertant committed Apr 17, 2018
1 parent d4b760b commit a403845
Show file tree
Hide file tree
Showing 10 changed files with 107 additions and 131 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ node_modules
nbproject/
coverage/
npm-debug.log
package-lock.json
1 change: 1 addition & 0 deletions .npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@ CONTRIBUTING.md
*.swm
.editorconfig
example
package-lock.json
15 changes: 6 additions & 9 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
language: node_js
node_js:
- "4"
- "6"
- "8"
- '4'
- '6'
- '8'
- '9'

after_script:
- npm run coverage && cat ./coverage/lcov.info | ./node_modules/.bin/codeclimate
addons:
code_climate:
repo_token: 351483555263cf9bcd2416c58b0e0ae6ca1b32438aa51bbab2c833560fb67cc0
sudo: false
after_success:
- npm run coveralls
24 changes: 0 additions & 24 deletions Makefile

This file was deleted.

13 changes: 8 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,15 @@
},
"devDependencies": {
"codeclimate-test-reporter": "0.4.0",
"coveralls": "^3.0.0",
"eslint": "3.11.1",
"espree": "3.3.2",
"istanbul": "0.4.5",
"should": "11.1.1",
"mocha": "3.2.0",
"mocha-lcov-reporter": "^1.3.0",
"offshore-adapter-tests": "~1.0.0",
"offshore-memory": "~0.1.0",
"offshore-adapter-tests": "Atlantis-Software/offshore-adapter-tests",
"mocha": "3.2.0"
"should": "11.1.1"
},
"keywords": [
"mvc",
Expand All @@ -42,10 +44,11 @@
"repository": "git://github.com/Atlantis-Software/offshore.git",
"main": "./lib/offshore",
"scripts": {
"test": "make test",
"test": "node ./test/runner.js",
"cover": "istanbul cover ./test/runner.js",
"coveralls": "npm run cover -- --report lcovonly && cat ./coverage/lcov.info | coveralls",
"prepublish": "npm prune",
"browserify": "rm -rf .dist && mkdir .dist && browserify lib/offshore.js -s Offshore | uglifyjs > .dist/offshore.min.js",
"coverage": "make coverage",
"lint": "eslint lib --reset"
},
"engines": {
Expand Down
93 changes: 0 additions & 93 deletions test/adapter/runner.js

This file was deleted.

91 changes: 91 additions & 0 deletions test/runner.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
var fs = require('fs');
var path = require('path');
var util = require('util');
process.env.offshorePath = path.join(__dirname, '..');
var TestRunner = require('offshore-adapter-tests');
var Mocha = require('mocha');

var mocha = new Mocha();

(function getTestFiles(dir) {
files = fs.readdirSync(dir);
files.forEach(function(file) {
if (fs.statSync(path.join(dir, file)).isDirectory()) {
return getTestFiles(path.join(dir, file));
}
mocha.addFile(path.join(dir, file));
});
})(__dirname);

mocha.run(function(failures) {
if (failures) {
process.on('exit', function() {
process.exit(failures);
});
} else {
var adapterName = 'offshore-memory';
var Adapter = require(adapterName);

// Grab targeted interfaces from this adapter's `package.json` file:
var package = {};
var interfaces = [];
var features = [];
try {
package = require('../node_modules/' + adapterName + '/package.json');
interfaces = package['offshoreAdapter'].interfaces;
features = package.offshoreAdapter.features;
}
catch (e) {
throw new Error(
'\n'+
'Could not read supported interfaces from "offshore-adapter"."interfaces"'+'\n' +
'in this adapter\'s `package.json` file ::' + '\n' +
util.inspect(e)
);
}

console.info('Testing `' + package.name + '`, an offshore adapter.');
console.info('Running `offshore-adapter-tests` against ' + interfaces.length + ' interfaces...');
console.info('( ' + interfaces.join(', ') + ' )');
console.log();

/**
* Integration Test Runner
*
* Uses the `offshore-adapter-tests` module to
* run mocha tests against the specified interfaces
* of the currently-implemented Offshore adapter API.
*/
new TestRunner({

// Load the adapter module.
adapter: Adapter,

// Default adapter config to use.
config: {
schema: false
},

// The set of adapter interfaces to test against.
// (grabbed these from this adapter's package.json file above)
interfaces: interfaces,

// The set of adapter features to test against.
// (grabbed these from this adapter's package.json file above)
features: features,

// Mocha options
// reference: https://github.com/mochajs/mocha/wiki/Using-mocha-programmatically
mocha: {
reporter: 'spec'
},

mochaChainableMethods: {},

// Return code 1 if any test failed
failOnError: true
});

}

});
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit a403845

Please sign in to comment.