Skip to content

Commit

Permalink
Merge pull request #21 from mongodb-js/electron-upgrade
Browse files Browse the repository at this point in the history
COMPASS-3933: Update dependencies
  • Loading branch information
imlucas committed Jan 14, 2020
1 parent 275487d commit 3b71517
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 78 deletions.
13 changes: 3 additions & 10 deletions packages/storage-mixin/.travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ sudo: required
# dist: trusty
language: node_js
node_js:
- 10.2.1
- 12.4.0

env:
global:
Expand All @@ -11,12 +11,6 @@ env:
- CXX=clang++
- npm_config_clang=1

# matrix:
# include:
# - env: NODE=1
# - env: ELECTRON=1
# fast_finish: true

before_install:
- npm i -g npm@latest

Expand All @@ -31,7 +25,8 @@ before_script:
eval $(/usr/bin/gnome-keyring-daemon --components=secrets --start);
/usr/bin/python -c "import gnomekeyring;gnomekeyring.create_sync('login', '');";
script:
- npm run ci
- npm run check
- npm run test:node
# - if [ -n "$NODE" ]; then npm run test:node; fi
# - if [ -n "$ELECTRON" ]; then npm run test:electron; fi

Expand All @@ -41,7 +36,5 @@ addons:
- ubuntu-toolchain-r-test
packages:
- libsecret-1-dev
# TODO (@imlucas) Are all of these gnome keyring
# packages really needed?
- gnome-keyring
- python-gnomekeyring
12 changes: 8 additions & 4 deletions packages/storage-mixin/lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,12 @@ module.exports = {
}
},
_initializeMixin: function() {
var storage = (typeof this.storage === 'object') ? this.storage : {
backend: this.storage
};
var storage = this.storage;
if (typeof this.storage !== 'object') {
storage = {
backend: this.storage
};
}
storage.namespace = this.namespace;
this._storageBackend = new backends[storage.backend](storage);
},
Expand All @@ -38,7 +41,8 @@ module.exports = {
};

options.error = function(resp, err) {
debug('WTF', {err: err, resp: resp});
debug('Unexpected storage-mixin sync error', { err: err, resp: resp });
throw err;
};
this.fetched = false;
this._storageBackend.exec(method, model, options);
Expand Down
33 changes: 16 additions & 17 deletions packages/storage-mixin/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,32 +29,31 @@
"scripts": {
"pretest:electron": "electron-rebuild --force --only keytar",
"test:electron": "electron-mocha --renderer",
"pretest:node": "node-gyp rebuild --directory node_modules/keytar/ --verbose",
"pretest:node": "node-gyp rebuild --directory node_modules/keytar/",
"test:node": "mocha",
"check": "mongodb-js-precommit",
"ci": "npm run check && npm run test",
"test": "npm run test:node && npm run test:electron"
},
"dependencies": {
"ampersand-model": "^6.0.2",
"ampersand-rest-collection": "^5.0.0",
"ampersand-sync": "^4.0.3",
"async": "^1.5.0",
"debug": "^4.1.0",
"ampersand-model": "^8.0.1",
"ampersand-rest-collection": "^6.0.0",
"ampersand-sync": "^5.1.0",
"async": "^3.1.0",
"debug": "^4.1.1",
"hadron-ipc": "^1.1.0",
"keytar": "^4.4.1",
"localforage": "^1.3.0",
"lodash": "^4.13.1",
"rimraf": "^2.4.4",
"keytar": "^5.0.0",
"localforage": "^1.7.3",
"lodash": "^4.17.15",
"rimraf": "^3.0.0",
"uuid": "^3.3.3",
"write-file-atomic": "^1.1.4"
"write-file-atomic": "^3.0.1"
},
"devDependencies": {
"electron": "^4.0.0",
"electron-mocha": "^6.0.4",
"electron-rebuild": "^1.8.2",
"eslint-config-mongodb-js": "^3.0.1",
"mocha": "^5.2.0",
"electron": "^6.0.0",
"electron-mocha": "^8.1.2",
"electron-rebuild": "^1.8.8",
"eslint-config-mongodb-js": "^5.0.3",
"mocha": "^7.0.0",
"mongodb-js-precommit": "^2.0.0"
}
}
41 changes: 16 additions & 25 deletions packages/storage-mixin/test/disk.test.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
var storageMixin = require('../lib');
var assert = require('assert');
var async = require('async');
var fs = require('fs');
var helpers = require('./helpers');

// var debug = require('debug')('storage-mixin:test');
Expand Down Expand Up @@ -38,16 +36,6 @@ describe('storage backend disk', function() {
helpers.clearNamespaces('disk', ['Spaceships', 'Planets'], done);
});

after(function(done) {
async.some(['./Planets', './Spaceships'], fs.exists, function(result) {
// if result is true then at least one of the files exists
if (result) {
return done(new Error('orphaned files left after tests.'));
}
done();
});
});

var spaceship;
var fleet;
beforeEach(function() {
Expand All @@ -61,19 +49,22 @@ describe('storage backend disk', function() {
});

it('should update and read correctly', function(done) {
spaceship.save({warpSpeed: 3.14}, {
success: function() {
var otherSpaceship = new StorableSpaceship({
name: 'Battlestar Galactica'
});
otherSpaceship.once('sync', function() {
assert.equal(otherSpaceship.warpSpeed, 3.14);
done();
});
otherSpaceship.fetch();
},
error: done
});
spaceship.save(
{ warpSpeed: 3.14 },
{
success: function() {
var otherSpaceship = new StorableSpaceship({
name: 'Battlestar Galactica'
});
otherSpaceship.once('sync', function() {
assert.equal(otherSpaceship.warpSpeed, 3.14);
done();
});
otherSpaceship.fetch();
},
error: done
}
);
});

it('should store a second model in the same namespace', function(done) {
Expand Down
32 changes: 10 additions & 22 deletions packages/storage-mixin/test/splice-disk.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ var SecureBackend = require('../lib/backends').secure;
var SpliceDiskBackend = require('../lib/backends')['splice-disk'];
var wrapErrback = require('../lib/backends/errback').wrapErrback;
var helpers = require('./helpers');
var fs = require('fs');
var assert = require('assert');
var async = require('async');
var debug = require('debug')('storage-mixin:splice:test');
Expand Down Expand Up @@ -49,30 +48,19 @@ describe('storage backend splice-disk', function() {

// clear namespaces of this backend before and after the tests
before(function(done) {
helpers.clearNamespaces('splice-disk', ['Spaceships', 'Planets', 'Users'], done);
});

after(function(done) {
helpers.clearNamespaces('splice-disk', ['Spaceships', 'Planets', 'Users'], done);
});

after(function(done) {
async.some(['./Planets', './Spaceships', './Users'], fs.exists, function(result) {
// if result is true then at least one of the files exists
if (result) {
return done(new Error('orphaned files left after tests.'));
}
done();
});
helpers.clearNamespaces(
'splice-disk',
['Spaceships', 'Planets', 'Users'],
done
);
});

after(function(done) {
fleet = new StorableFleet();
fleet.once('sync', function() {
assert.equal(fleet.length, 0);
done();
});
fleet.fetch();
helpers.clearNamespaces(
'splice-disk',
['Spaceships', 'Planets', 'Users'],
done
);
});

beforeEach(function() {
Expand Down

0 comments on commit 3b71517

Please sign in to comment.