Skip to content

Commit 3a20220

Browse files
jmdobryAce Nassri
authored and
Ace Nassri
committed
Cleanup App Engine samples and re-work tests. (#354)
1 parent 2a66881 commit 3a20220

File tree

9 files changed

+3616
-328
lines changed

9 files changed

+3616
-328
lines changed

compute/mailjet.js

+14-12
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
1-
// Copyright 2016, Google, Inc.
2-
// Licensed under the Apache License, Version 2.0 (the "License");
3-
// you may not use this file except in compliance with the License.
4-
// You may obtain a copy of the License at
5-
//
6-
// http://www.apache.org/licenses/LICENSE-2.0
7-
//
8-
// Unless required by applicable law or agreed to in writing, software
9-
// distributed under the License is distributed on an "AS IS" BASIS,
10-
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11-
// See the License for the specific language governing permissions and
12-
// limitations under the License.
1+
/**
2+
* Copyright 2017, Google, Inc.
3+
* Licensed under the Apache License, Version 2.0 (the "License");
4+
* you may not use this file except in compliance with the License.
5+
* You may obtain a copy of the License at
6+
*
7+
* http://www.apache.org/licenses/LICENSE-2.0
8+
*
9+
* Unless required by applicable law or agreed to in writing, software
10+
* distributed under the License is distributed on an "AS IS" BASIS,
11+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
* See the License for the specific language governing permissions and
13+
* limitations under the License.
14+
*/
1315

1416
'use strict';
1517

compute/package.json

+27-8
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,36 @@
22
"name": "nodejs-docs-samples-computeengine",
33
"version": "0.0.1",
44
"private": true,
5-
"license": "Apache Version 2.0",
5+
"license": "Apache-2.0",
66
"author": "Google Inc.",
7+
"repository": {
8+
"type": "git",
9+
"url": "https://github.com/GoogleCloudPlatform/nodejs-docs-samples.git"
10+
},
11+
"cloud": {
12+
"requiresKeyFile": true,
13+
"requiresProjectId": true
14+
},
15+
"engines": {
16+
"node": ">=4.3.2"
17+
},
718
"scripts": {
8-
"test": "cd ..; npm run t -- computeengine/test/*.test.js",
9-
"system-test": "cd ..; npm run t -- computeengine/system-test/*.test.js"
19+
"lint": "samples lint",
20+
"pretest": "npm run lint",
21+
"unit-test": "ava -T 20s --verbose test/*.test.js",
22+
"system-test": "ava -T 20s --verbose system-test/*.test.js",
23+
"test": "npm run unit-test && npm run system-test"
1024
},
1125
"dependencies": {
12-
"@google-cloud/compute": "0.6.0",
13-
"googleapis": "18.0.0",
14-
"nodemailer": "2.7.0",
15-
"nodemailer-smtp-transport": "2.7.2",
16-
"sendgrid": "4.7.1"
26+
"@google-cloud/compute": "0.7.1",
27+
"googleapis": "19.0.0",
28+
"nodemailer": "4.0.1",
29+
"nodemailer-smtp-transport": "2.7.4",
30+
"sendgrid": "5.0.0"
31+
},
32+
"devDependencies": {
33+
"@google-cloud/nodejs-repo-tools": "1.3.1",
34+
"ava": "0.19.1",
35+
"proxyquire": "1.7.11"
1736
}
1837
}

compute/system-test/vms.test.js

+19-15
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,28 @@
1-
// Copyright 2016, Google, Inc.
2-
// Licensed under the Apache License, Version 2.0 (the "License");
3-
// you may not use this file except in compliance with the License.
4-
// You may obtain a copy of the License at
5-
//
6-
// http://www.apache.org/licenses/LICENSE-2.0
7-
//
8-
// Unless required by applicable law or agreed to in writing, software
9-
// distributed under the License is distributed on an "AS IS" BASIS,
10-
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11-
// See the License for the specific language governing permissions and
12-
// limitations under the License.
1+
/**
2+
* Copyright 2017, Google, Inc.
3+
* Licensed under the Apache License, Version 2.0 (the "License");
4+
* you may not use this file except in compliance with the License.
5+
* You may obtain a copy of the License at
6+
*
7+
* http://www.apache.org/licenses/LICENSE-2.0
8+
*
9+
* Unless required by applicable law or agreed to in writing, software
10+
* distributed under the License is distributed on an "AS IS" BASIS,
11+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
* See the License for the specific language governing permissions and
13+
* limitations under the License.
14+
*/
1315

1416
'use strict';
1517

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

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

20-
test.beforeEach(stubConsole);
21-
test.afterEach.always(restoreConsole);
23+
test.before(tools.checkCredentials);
24+
test.beforeEach(tools.stubConsole);
25+
test.afterEach.always(tools.restoreConsole);
2226

2327
test.cb(`should retrieve vms`, (t) => {
2428
vmsExample.main((err, result) => {

compute/system-test/vms_api.test.js

+19-15
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,28 @@
1-
// Copyright 2016, Google, Inc.
2-
// Licensed under the Apache License, Version 2.0 (the "License");
3-
// you may not use this file except in compliance with the License.
4-
// You may obtain a copy of the License at
5-
//
6-
// http://www.apache.org/licenses/LICENSE-2.0
7-
//
8-
// Unless required by applicable law or agreed to in writing, software
9-
// distributed under the License is distributed on an "AS IS" BASIS,
10-
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11-
// See the License for the specific language governing permissions and
12-
// limitations under the License.
1+
/**
2+
* Copyright 2017, Google, Inc.
3+
* Licensed under the Apache License, Version 2.0 (the "License");
4+
* you may not use this file except in compliance with the License.
5+
* You may obtain a copy of the License at
6+
*
7+
* http://www.apache.org/licenses/LICENSE-2.0
8+
*
9+
* Unless required by applicable law or agreed to in writing, software
10+
* distributed under the License is distributed on an "AS IS" BASIS,
11+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
* See the License for the specific language governing permissions and
13+
* limitations under the License.
14+
*/
1315

1416
'use strict';
1517

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

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

20-
test.beforeEach(stubConsole);
21-
test.afterEach.always(restoreConsole);
23+
test.before(tools.checkCredentials);
24+
test.beforeEach(tools.stubConsole);
25+
test.afterEach.always(tools.restoreConsole);
2226

2327
test.cb('should retrieve vms', (t) => {
2428
vmsExample.main((err, result) => {

compute/test/mailjet.test.js

+20-17
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,29 @@
1-
// Copyright 2016, Google, Inc.
2-
// Licensed under the Apache License, Version 2.0 (the "License");
3-
// you may not use this file except in compliance with the License.
4-
// You may obtain a copy of the License at
5-
//
6-
// http://www.apache.org/licenses/LICENSE-2.0
7-
//
8-
// Unless required by applicable law or agreed to in writing, software
9-
// distributed under the License is distributed on an "AS IS" BASIS,
10-
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11-
// See the License for the specific language governing permissions and
12-
// limitations under the License.
1+
/**
2+
* Copyright 2017, Google, Inc.
3+
* Licensed under the Apache License, Version 2.0 (the "License");
4+
* you may not use this file except in compliance with the License.
5+
* You may obtain a copy of the License at
6+
*
7+
* http://www.apache.org/licenses/LICENSE-2.0
8+
*
9+
* Unless required by applicable law or agreed to in writing, software
10+
* distributed under the License is distributed on an "AS IS" BASIS,
11+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
* See the License for the specific language governing permissions and
13+
* limitations under the License.
14+
*/
1315

1416
'use strict';
1517

16-
require(`../../test/_setup`);
17-
1818
const proxyquire = require(`proxyquire`).noPreserveCache();
19+
const test = require(`ava`);
20+
const tools = require(`@google-cloud/nodejs-repo-tools`);
21+
1922
process.env.MAILJET_API_KEY = `foo`;
2023
process.env.MAILJET_API_SECRET = `bar`;
2124

22-
test.beforeEach(stubConsole);
23-
test.afterEach.always(restoreConsole);
25+
test.beforeEach(tools.stubConsole);
26+
test.afterEach.always(tools.restoreConsole);
2427

2528
test.cb(`should send an email`, (t) => {
2629
proxyquire(`../mailjet`, {
@@ -35,7 +38,7 @@ test.cb(`should send an email`, (t) => {
3538
subject: `test email from Node.js on Google Cloud Platform`,
3639
text: `Hello!\n\nThis a test email from Node.js.`
3740
});
38-
cb(`done`);
41+
cb(null, `done`);
3942
t.end();
4043
}
4144
};

compute/test/sendgrid.test.js

+19-16
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,28 @@
1-
// Copyright 2015-2016, Google, Inc.
2-
// Licensed under the Apache License, Version 2.0 (the "License");
3-
// you may not use this file except in compliance with the License.
4-
// You may obtain a copy of the License at
5-
//
6-
// http://www.apache.org/licenses/LICENSE-2.0
7-
//
8-
// Unless required by applicable law or agreed to in writing, software
9-
// distributed under the License is distributed on an "AS IS" BASIS,
10-
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11-
// See the License for the specific language governing permissions and
12-
// limitations under the License.
1+
/**
2+
* Copyright 2017, Google, Inc.
3+
* Licensed under the Apache License, Version 2.0 (the "License");
4+
* you may not use this file except in compliance with the License.
5+
* You may obtain a copy of the License at
6+
*
7+
* http://www.apache.org/licenses/LICENSE-2.0
8+
*
9+
* Unless required by applicable law or agreed to in writing, software
10+
* distributed under the License is distributed on an "AS IS" BASIS,
11+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
* See the License for the specific language governing permissions and
13+
* limitations under the License.
14+
*/
1315

1416
'use strict';
1517

16-
require(`../../test/_setup`);
17-
1818
const proxyquire = require(`proxyquire`).noPreserveCache();
19+
const test = require(`ava`);
20+
const tools = require(`@google-cloud/nodejs-repo-tools`);
21+
1922
process.env.SENDGRID_API_KEY = `foo`;
2023

21-
test.beforeEach(stubConsole);
22-
test.afterEach.always(restoreConsole);
24+
test.beforeEach(tools.stubConsole);
25+
test.afterEach.always(tools.restoreConsole);
2326

2427
test.cb(`should send an email`, (t) => {
2528
proxyquire(`../sendgrid`, {

compute/vms.js

+14-12
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
1-
// Copyright 2016, Google, Inc.
2-
// Licensed under the Apache License, Version 2.0 (the "License");
3-
// you may not use this file except in compliance with the License.
4-
// You may obtain a copy of the License at
5-
//
6-
// http://www.apache.org/licenses/LICENSE-2.0
7-
//
8-
// Unless required by applicable law or agreed to in writing, software
9-
// distributed under the License is distributed on an "AS IS" BASIS,
10-
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11-
// See the License for the specific language governing permissions and
12-
// limitations under the License.
1+
/**
2+
* Copyright 2017, Google, Inc.
3+
* Licensed under the Apache License, Version 2.0 (the "License");
4+
* you may not use this file except in compliance with the License.
5+
* You may obtain a copy of the License at
6+
*
7+
* http://www.apache.org/licenses/LICENSE-2.0
8+
*
9+
* Unless required by applicable law or agreed to in writing, software
10+
* distributed under the License is distributed on an "AS IS" BASIS,
11+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
* See the License for the specific language governing permissions and
13+
* limitations under the License.
14+
*/
1315

1416
// [START complete]
1517
'use strict';

compute/vms_api.js

+14-12
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
1-
// Copyright 2016, Google, Inc.
2-
// Licensed under the Apache License, Version 2.0 (the "License");
3-
// you may not use this file except in compliance with the License.
4-
// You may obtain a copy of the License at
5-
//
6-
// http://www.apache.org/licenses/LICENSE-2.0
7-
//
8-
// Unless required by applicable law or agreed to in writing, software
9-
// distributed under the License is distributed on an "AS IS" BASIS,
10-
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11-
// See the License for the specific language governing permissions and
12-
// limitations under the License.
1+
/**
2+
* Copyright 2017, Google, Inc.
3+
* Licensed under the Apache License, Version 2.0 (the "License");
4+
* you may not use this file except in compliance with the License.
5+
* You may obtain a copy of the License at
6+
*
7+
* http://www.apache.org/licenses/LICENSE-2.0
8+
*
9+
* Unless required by applicable law or agreed to in writing, software
10+
* distributed under the License is distributed on an "AS IS" BASIS,
11+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
* See the License for the specific language governing permissions and
13+
* limitations under the License.
14+
*/
1315

1416
'use strict';
1517

0 commit comments

Comments
 (0)