diff --git a/compute/package.json b/compute/package.json index 47a0cae4b3..cc0148f29a 100644 --- a/compute/package.json +++ b/compute/package.json @@ -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" } } diff --git a/compute/system-test/mailjet.test.js b/compute/system-test/mailjet.test.js new file mode 100644 index 0000000000..1887d6a08f --- /dev/null +++ b/compute/system-test/mailjet.test.js @@ -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'); +}); diff --git a/compute/system-test/sendgrid.test.js b/compute/system-test/sendgrid.test.js new file mode 100644 index 0000000000..15347ecd4e --- /dev/null +++ b/compute/system-test/sendgrid.test.js @@ -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'); +}); diff --git a/compute/system-test/vms.test.js b/compute/system-test/vms.test.js new file mode 100644 index 0000000000..52f4b2b804 --- /dev/null +++ b/compute/system-test/vms.test.js @@ -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(); + }); + }); +}); diff --git a/compute/system-test/vms_api.test.js b/compute/system-test/vms_api.test.js new file mode 100644 index 0000000000..cf89dc85a5 --- /dev/null +++ b/compute/system-test/vms_api.test.js @@ -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(); + }); + }); +}); diff --git a/compute/test/mailjet.test.js b/compute/test/mailjet.test.js new file mode 100644 index 0000000000..1e9989b97f --- /dev/null +++ b/compute/test/mailjet.test.js @@ -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@EXAMPLE.COM', + 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'; + } + }); + }); +}); diff --git a/compute/test/sendgrid.test.js b/compute/test/sendgrid.test.js new file mode 100644 index 0000000000..92a5427596 --- /dev/null +++ b/compute/test/sendgrid.test.js @@ -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@EXAMPLE.COM', + subject: 'test email from Node.js on Google Cloud Platform', + text: 'Hello!\n\nThis a test email from Node.js.' + }); + cb('done'); + done(); + } + }; + } + }); + }); +}); diff --git a/compute/test/vms.test.js b/compute/test/vms.test.js new file mode 100644 index 0000000000..1374d33def --- /dev/null +++ b/compute/test/vms.test.js @@ -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'); +}); diff --git a/compute/test/vms_api.test.js b/compute/test/vms_api.test.js new file mode 100644 index 0000000000..ca47b156f9 --- /dev/null +++ b/compute/test/vms_api.test.js @@ -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'); +});