Skip to content

Commit

Permalink
Cleanup App Engine samples and re-work tests. (#354)
Browse files Browse the repository at this point in the history
  • Loading branch information
jmdobry authored and Ace Nassri committed Nov 21, 2022
1 parent f6c1033 commit 076c48b
Show file tree
Hide file tree
Showing 9 changed files with 3,616 additions and 328 deletions.
26 changes: 14 additions & 12 deletions compute/mailjet.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
// 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.
/**
* Copyright 2017, 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';

Expand Down
35 changes: 27 additions & 8 deletions compute/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,36 @@
"name": "nodejs-docs-samples-computeengine",
"version": "0.0.1",
"private": true,
"license": "Apache Version 2.0",
"license": "Apache-2.0",
"author": "Google Inc.",
"repository": {
"type": "git",
"url": "https://github.com/GoogleCloudPlatform/nodejs-docs-samples.git"
},
"cloud": {
"requiresKeyFile": true,
"requiresProjectId": true
},
"engines": {
"node": ">=4.3.2"
},
"scripts": {
"test": "cd ..; npm run t -- computeengine/test/*.test.js",
"system-test": "cd ..; npm run t -- computeengine/system-test/*.test.js"
"lint": "samples lint",
"pretest": "npm run lint",
"unit-test": "ava -T 20s --verbose test/*.test.js",
"system-test": "ava -T 20s --verbose system-test/*.test.js",
"test": "npm run unit-test && npm run system-test"
},
"dependencies": {
"@google-cloud/compute": "0.6.0",
"googleapis": "18.0.0",
"nodemailer": "2.7.0",
"nodemailer-smtp-transport": "2.7.2",
"sendgrid": "4.7.1"
"@google-cloud/compute": "0.7.1",
"googleapis": "19.0.0",
"nodemailer": "4.0.1",
"nodemailer-smtp-transport": "2.7.4",
"sendgrid": "5.0.0"
},
"devDependencies": {
"@google-cloud/nodejs-repo-tools": "1.3.1",
"ava": "0.19.1",
"proxyquire": "1.7.11"
}
}
34 changes: 19 additions & 15 deletions compute/system-test/vms.test.js
Original file line number Diff line number Diff line change
@@ -1,24 +1,28 @@
// 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.
/**
* Copyright 2017, 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';

require(`../../system-test/_setup`);
const test = require(`ava`);
const tools = require(`@google-cloud/nodejs-repo-tools`);

const vmsExample = require(`../vms`);

test.beforeEach(stubConsole);
test.afterEach.always(restoreConsole);
test.before(tools.checkCredentials);
test.beforeEach(tools.stubConsole);
test.afterEach.always(tools.restoreConsole);

test.cb(`should retrieve vms`, (t) => {
vmsExample.main((err, result) => {
Expand Down
34 changes: 19 additions & 15 deletions compute/system-test/vms_api.test.js
Original file line number Diff line number Diff line change
@@ -1,24 +1,28 @@
// 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.
/**
* Copyright 2017, 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';

require(`../../system-test/_setup`);
const test = require(`ava`);
const tools = require(`@google-cloud/nodejs-repo-tools`);

const vmsExample = require(`../vms_api`);

test.beforeEach(stubConsole);
test.afterEach.always(restoreConsole);
test.before(tools.checkCredentials);
test.beforeEach(tools.stubConsole);
test.afterEach.always(tools.restoreConsole);

test.cb('should retrieve vms', (t) => {
vmsExample.main((err, result) => {
Expand Down
37 changes: 20 additions & 17 deletions compute/test/mailjet.test.js
Original file line number Diff line number Diff line change
@@ -1,26 +1,29 @@
// 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.
/**
* Copyright 2017, 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';

require(`../../test/_setup`);

const proxyquire = require(`proxyquire`).noPreserveCache();
const test = require(`ava`);
const tools = require(`@google-cloud/nodejs-repo-tools`);

process.env.MAILJET_API_KEY = `foo`;
process.env.MAILJET_API_SECRET = `bar`;

test.beforeEach(stubConsole);
test.afterEach.always(restoreConsole);
test.beforeEach(tools.stubConsole);
test.afterEach.always(tools.restoreConsole);

test.cb(`should send an email`, (t) => {
proxyquire(`../mailjet`, {
Expand All @@ -35,7 +38,7 @@ test.cb(`should send an email`, (t) => {
subject: `test email from Node.js on Google Cloud Platform`,
text: `Hello!\n\nThis a test email from Node.js.`
});
cb(`done`);
cb(null, `done`);
t.end();
}
};
Expand Down
35 changes: 19 additions & 16 deletions compute/test/sendgrid.test.js
Original file line number Diff line number Diff line change
@@ -1,25 +1,28 @@
// 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.
/**
* Copyright 2017, 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';

require(`../../test/_setup`);

const proxyquire = require(`proxyquire`).noPreserveCache();
const test = require(`ava`);
const tools = require(`@google-cloud/nodejs-repo-tools`);

process.env.SENDGRID_API_KEY = `foo`;

test.beforeEach(stubConsole);
test.afterEach.always(restoreConsole);
test.beforeEach(tools.stubConsole);
test.afterEach.always(tools.restoreConsole);

test.cb(`should send an email`, (t) => {
proxyquire(`../sendgrid`, {
Expand Down
26 changes: 14 additions & 12 deletions compute/vms.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
// 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.
/**
* Copyright 2017, 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.
*/

// [START complete]
'use strict';
Expand Down
26 changes: 14 additions & 12 deletions compute/vms_api.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
// 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.
/**
* Copyright 2017, 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';

Expand Down
Loading

0 comments on commit 076c48b

Please sign in to comment.