Skip to content

Commit 31d119b

Browse files
authored
Refactored tests (#159)
* 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
1 parent b325808 commit 31d119b

9 files changed

+226
-6
lines changed

compute/package.json

+9-6
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,21 @@
11
{
2-
"name": "computeengine",
3-
"description": "Collection of Node.js samples on Google Compute Engine.",
2+
"name": "nodejs-docs-samples-computeengine",
43
"version": "0.0.1",
54
"private": true,
65
"license": "Apache Version 2.0",
76
"author": "Google Inc.",
8-
"engines": {
9-
"node": ">=0.10.x"
7+
"scripts": {
8+
"test": "mocha -R spec -t 120000 --require intelli-espower-loader ../test/_setup.js test/*.test.js",
9+
"system-test": "mocha -R spec -t 120000 --require intelli-espower-loader ../system-test/_setup.js system-test/*.test.js"
1010
},
1111
"dependencies": {
12-
"gcloud": "^0.34.0",
13-
"googleapis": "^7.1.0",
12+
"gcloud": "^0.37.0",
13+
"googleapis": "^12.0.0",
1414
"nodemailer": "^2.4.1",
1515
"nodemailer-smtp-transport": "^2.5.0",
1616
"sendgrid": "^2.0.0"
17+
},
18+
"devDependencies": {
19+
"mocha": "^2.5.3"
1720
}
1821
}

compute/system-test/mailjet.test.js

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
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.
13+
14+
'use strict';
15+
16+
describe('computeengine:mailjet', function () {
17+
it('should be tested');
18+
});

compute/system-test/sendgrid.test.js

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
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.
13+
14+
'use strict';
15+
16+
describe('computeengine:sendgrid', function () {
17+
it('should be tested');
18+
});

compute/system-test/vms.test.js

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
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.
13+
14+
'use strict';
15+
16+
var vmsExample = require('../vms');
17+
18+
describe('computeengine:vms', function () {
19+
it('should retrieve vms', function (done) {
20+
vmsExample.main(function (err, result) {
21+
assert(!err);
22+
assert(result);
23+
assert(Array.isArray(result));
24+
done();
25+
});
26+
});
27+
});

compute/system-test/vms_api.test.js

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
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.
13+
14+
'use strict';
15+
16+
var vmsExample = require('../vms_api');
17+
18+
describe('computeengine:vms_api', function () {
19+
it('should retrieve vms', function (done) {
20+
vmsExample.main(function (err, result) {
21+
assert(!err);
22+
assert(result);
23+
done();
24+
});
25+
});
26+
});

compute/test/mailjet.test.js

+53
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
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.
13+
14+
'use strict';
15+
16+
var proxyquire = require('proxyquire').noPreserveCache();
17+
process.env.MAILJET_API_KEY = 'foo';
18+
process.env.MAILJET_API_SECRET = 'bar';
19+
20+
describe('computeengine:mailjet', function () {
21+
it('should send an email', function (done) {
22+
proxyquire('../mailjet', {
23+
nodemailer: {
24+
createTransport: function (arg) {
25+
assert.equal(arg, 'test');
26+
return {
27+
sendMail: function (payload, cb) {
28+
assert.deepEqual(payload, {
29+
from: 'ANOTHER_EMAIL@ANOTHER_EXAMPLE.COM',
30+
31+
subject: 'test email from Node.js on Google Cloud Platform',
32+
text: 'Hello!\n\nThis a test email from Node.js.'
33+
});
34+
cb('done');
35+
done();
36+
}
37+
};
38+
}
39+
},
40+
'nodemailer-smtp-transport': function (options) {
41+
assert.deepEqual(options, {
42+
host: 'in.mailjet.com',
43+
port: 2525,
44+
auth: {
45+
user: 'foo',
46+
pass: 'bar'
47+
}
48+
});
49+
return 'test';
50+
}
51+
});
52+
});
53+
});

compute/test/sendgrid.test.js

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
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.
13+
14+
'use strict';
15+
16+
var proxyquire = require('proxyquire').noPreserveCache();
17+
process.env.SENDGRID_API_KEY = 'foo';
18+
19+
describe('computeengine:sendgrid', function () {
20+
it('should send an email', function (done) {
21+
proxyquire('../sendgrid', {
22+
sendgrid: function (key) {
23+
assert.equal(key, 'foo');
24+
return {
25+
send: function (payload, cb) {
26+
assert.deepEqual(payload, {
27+
from: 'ANOTHER_EMAIL@ANOTHER_EXAMPLE.COM',
28+
29+
subject: 'test email from Node.js on Google Cloud Platform',
30+
text: 'Hello!\n\nThis a test email from Node.js.'
31+
});
32+
cb('done');
33+
done();
34+
}
35+
};
36+
}
37+
});
38+
});
39+
});

compute/test/vms.test.js

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
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.
13+
14+
'use strict';
15+
16+
describe('computeengine:vms', function () {
17+
it('should be tested');
18+
});

compute/test/vms_api.test.js

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
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.
13+
14+
'use strict';
15+
16+
describe('computeengine:vms_api', function () {
17+
it('should be tested');
18+
});

0 commit comments

Comments
 (0)