Skip to content

Commit

Permalink
Merge pull request #3 from tonymet/feature/smaller-dependencies
Browse files Browse the repository at this point in the history
use @gcloud/datastore instead to reduce dependencies
  • Loading branch information
fabito authored Apr 12, 2018
2 parents 2e0ea9e + da7e13b commit 98236c2
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 12 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,6 @@ build/Release
# https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git
node_modules

.tmp/
.tmp/
credentials.json
.env
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@
},
"bugs": {
"url": "https://github.com/fabito/botkit-storage-datastore/issues"
},
},
"dependencies": {
"google-cloud": "^0.53.0"
"@google-cloud/datastore": "^1.4.0"
},
"devDependencies": {
"coveralls": "^2.11.9",
Expand Down
4 changes: 2 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
var gcloud = require('google-cloud');
var Datastore = require('@google-cloud/datastore');

/**
* The Botkit google cloud datastore driver
Expand All @@ -11,7 +11,7 @@ module.exports = function(config) {
throw new Error('projectId is required.');
}

var datastore = gcloud.datastore(config),
var datastore = Datastore(config),
namespace = config.namespace,
teamKind = config.teamKind || 'BotkitTeam',
channelKind = config.channelKind || 'BotkitChannel',
Expand Down
10 changes: 4 additions & 6 deletions tests/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ var should = require('should'),
require('should-sinon');

describe('Datastore', function() {
var gcloudMock,
var GCloudDatastore,
datastoreMock,
Storage;

Expand All @@ -21,12 +21,10 @@ describe('Datastore', function() {
runQuery: sinon.stub()
};

gcloudMock = {
datastore: sinon.stub().returns(datastoreMock)
};
GCloudDatastore = sinon.stub().returns(datastoreMock);

Storage = proxyquire('../src/index', {
'google-cloud': gcloudMock
'@google-cloud/datastore': GCloudDatastore
});

});
Expand All @@ -44,7 +42,7 @@ describe('Datastore', function() {
it('should initialize datastore with projectId', function() {
var config = {projectId: 'crystalbluepersuation'};
Storage(config);
gcloudMock.datastore.should.be.calledWith(config);
GCloudDatastore.should.be.calledWith(config);
});
});

Expand Down
2 changes: 1 addition & 1 deletion tests/it.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
var DatastoreStorage = require('../src');

var storage = new DatastoreStorage({
projectId: 'myproject',
projectId: process.env.projectId || 'myproject',
namespace: '---botkit---'
//,apiEndpoint: 'http://localhost:8888'
});
Expand Down

0 comments on commit 98236c2

Please sign in to comment.