Skip to content

Commit

Permalink
Refactored tests (#159)
Browse files Browse the repository at this point in the history
* Refactor tests.

* Tweak build.

* Tweak build.

* More tests.

* Tweak build.

* Tweak build.

* Fix build.

* Fix build.

* Speed up build.

* Fix build.

* Remove extra dep.

* Investigate why 0.12 fails.

* Scripts.

* More tests.

* Upgrades

* Upgrades

* Update readme
  • Loading branch information
jmdobry authored and Ace Nassri committed Nov 21, 2022
1 parent 5e7ec7f commit cad2e8c
Show file tree
Hide file tree
Showing 9 changed files with 226 additions and 6 deletions.
15 changes: 9 additions & 6 deletions compute/package.json
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
{
"name": "computeengine",
"description": "Collection of Node.js samples on Google Compute Engine.",
"name": "nodejs-docs-samples-computeengine",
"version": "0.0.1",
"private": true,
"license": "Apache Version 2.0",
"author": "Google Inc.",
"engines": {
"node": ">=0.10.x"
"scripts": {
"test": "mocha -R spec -t 120000 --require intelli-espower-loader ../test/_setup.js test/*.test.js",
"system-test": "mocha -R spec -t 120000 --require intelli-espower-loader ../system-test/_setup.js system-test/*.test.js"
},
"dependencies": {
"gcloud": "^0.34.0",
"googleapis": "^7.1.0",
"gcloud": "^0.37.0",
"googleapis": "^12.0.0",
"nodemailer": "^2.4.1",
"nodemailer-smtp-transport": "^2.5.0",
"sendgrid": "^2.0.0"
},
"devDependencies": {
"mocha": "^2.5.3"
}
}
18 changes: 18 additions & 0 deletions compute/system-test/mailjet.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// Copyright 2016, Google, Inc.
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

'use strict';

describe('computeengine:mailjet', function () {
it('should be tested');
});
18 changes: 18 additions & 0 deletions compute/system-test/sendgrid.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// Copyright 2016, Google, Inc.
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

'use strict';

describe('computeengine:sendgrid', function () {
it('should be tested');
});
27 changes: 27 additions & 0 deletions compute/system-test/vms.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// Copyright 2016, Google, Inc.
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

'use strict';

var vmsExample = require('../vms');

describe('computeengine:vms', function () {
it('should retrieve vms', function (done) {
vmsExample.main(function (err, result) {
assert(!err);
assert(result);
assert(Array.isArray(result));
done();
});
});
});
26 changes: 26 additions & 0 deletions compute/system-test/vms_api.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// Copyright 2016, Google, Inc.
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

'use strict';

var vmsExample = require('../vms_api');

describe('computeengine:vms_api', function () {
it('should retrieve vms', function (done) {
vmsExample.main(function (err, result) {
assert(!err);
assert(result);
done();
});
});
});
53 changes: 53 additions & 0 deletions compute/test/mailjet.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
// Copyright 2016, Google, Inc.
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

'use strict';

var proxyquire = require('proxyquire').noPreserveCache();
process.env.MAILJET_API_KEY = 'foo';
process.env.MAILJET_API_SECRET = 'bar';

describe('computeengine:mailjet', function () {
it('should send an email', function (done) {
proxyquire('../mailjet', {
nodemailer: {
createTransport: function (arg) {
assert.equal(arg, 'test');
return {
sendMail: function (payload, cb) {
assert.deepEqual(payload, {
from: 'ANOTHER_EMAIL@ANOTHER_EXAMPLE.COM',
to: '[email protected]',
subject: 'test email from Node.js on Google Cloud Platform',
text: 'Hello!\n\nThis a test email from Node.js.'
});
cb('done');
done();
}
};
}
},
'nodemailer-smtp-transport': function (options) {
assert.deepEqual(options, {
host: 'in.mailjet.com',
port: 2525,
auth: {
user: 'foo',
pass: 'bar'
}
});
return 'test';
}
});
});
});
39 changes: 39 additions & 0 deletions compute/test/sendgrid.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
// Copyright 2015-2016, Google, Inc.
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

'use strict';

var proxyquire = require('proxyquire').noPreserveCache();
process.env.SENDGRID_API_KEY = 'foo';

describe('computeengine:sendgrid', function () {
it('should send an email', function (done) {
proxyquire('../sendgrid', {
sendgrid: function (key) {
assert.equal(key, 'foo');
return {
send: function (payload, cb) {
assert.deepEqual(payload, {
from: 'ANOTHER_EMAIL@ANOTHER_EXAMPLE.COM',
to: '[email protected]',
subject: 'test email from Node.js on Google Cloud Platform',
text: 'Hello!\n\nThis a test email from Node.js.'
});
cb('done');
done();
}
};
}
});
});
});
18 changes: 18 additions & 0 deletions compute/test/vms.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// Copyright 2016, Google, Inc.
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

'use strict';

describe('computeengine:vms', function () {
it('should be tested');
});
18 changes: 18 additions & 0 deletions compute/test/vms_api.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// Copyright 2016, Google, Inc.
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

'use strict';

describe('computeengine:vms_api', function () {
it('should be tested');
});

0 comments on commit cad2e8c

Please sign in to comment.