Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ jobs:
build:
docker:
- image: circleci/node:8.12
- image: circleci/mongo:3.4

steps:
- checkout
Expand All @@ -23,8 +24,14 @@ jobs:
- run: npm run test

## Process test artifacts (reports, coverage etc)
- store_test_results:
path: test-results
- store_artifacts:
path: test-results
- store_artifacts:
path: mochawesome-report
- run: (cat ./coverage/lcov.info | npx coveralls) || true
- store_artifacts:
path: coverage
- run:
name: Upload code coverage
command: (cat ./coverage/lcov.info | npx coveralls) || true
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ data
package-lock.json
yarn.lock
.vscode

## Test results, code coverage etc
coverage
.nyc_output
mochawesome-report
test-results
.env
2 changes: 1 addition & 1 deletion lib/utils/typecast.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ function wrapSingleValue(value) {

const wrapped = {
type: detectedType,
value: value
value
};

return wrapped;
Expand Down
12 changes: 9 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
"migrate"
],
"scripts": {
"lint": "./node_modules/.bin/eslint .",
"test": "nyc mocha"
"lint": "eslint *.js lib/**/*.js test/**/*.js",
"test": "npm run lint && nyc mocha"
},
"main": "index.js",
"bin": {
Expand All @@ -43,11 +43,17 @@
"mongodb": "^3.0.10"
},
"devDependencies": {
"chai": "^4.2.0",
"dotenv": "^6.1.0",
"eslint": "^4.19.1",
"eslint-config-airbnb-base": "^12.1.0",
"eslint-plugin-import": "^2.9.0",
"mkdirp": "^0.5.1",
"mocha": "^5.2.0",
"mocha-junit-reporter": "^1.18.0",
"mocha-multi-reporters": "^1.1.7",
"mochawesome": "^3.1.1",
"nyc": "^13.1.0"
"nyc": "^13.1.0",
"rimraf": "^2.6.2"
}
}
45 changes: 41 additions & 4 deletions test/lib.test.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,45 @@
const assert = require('chai').assert;
require('dotenv').config();

const dbclone = require('../lib');
const rimraf = require('rimraf');
const mkdirp = require('mkdirp');

const DATADIR = `data/${Math.random().toString(36).slice(2)}`;
const TEST_MLAB_URL = process.env.TEST_MLAB_URL;
const getDBNameFromURL = URL => URL.slice(URL.lastIndexOf('/') + 1);

before(() => {
if (!TEST_MLAB_URL) {
throw new Error('TEST_MLAB_URL env var must be specified');
}
rimraf.sync('data');
mkdirp.sync(DATADIR);
});

describe('Library tests', () => {
it('should import data', async () => {
console.log(dbclone);
// TODO: Add actual test
describe('Library tests', async () => {
describe('Export', async () => {
it('should export data from mLab URL', async () => {
await new Promise((resolve) => {
dbclone.export({
host: TEST_MLAB_URL,
db: getDBNameFromURL(TEST_MLAB_URL),
dataDir: DATADIR,
}, (error, data) => {
assert.ok(!error, `Error was not null: ${error}`);
const expectedData = [{
collection: 'system.indexes',
documents: 1
},
{
collection: 'bios',
documents: 10
}
];
assert.deepEqual(data, expectedData, 'Returned data did not match expected value.');
resolve();
});
});
});
});
});
6 changes: 6 additions & 0 deletions test/mocha-multi-reporter.config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"reporterEnabled": "mochawesome, mocha-junit-reporter",
"mochaJunitReporterReporterOptions": {
"mochaFile": "test-results/mocha/results.xml"
}
}
3 changes: 2 additions & 1 deletion test/mocha.opts
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
--reporter mochawesome
--reporter mocha-multi-reporters
--reporter-options configFile=test/mocha-multi-reporter.config.json