Skip to content

Commit 08560e5

Browse files
committed
Merge pull request GoogleCloudPlatform#50 from GoogleCloudPlatform/test-deploy
Added deployment tests
2 parents e06427d + ea04fba commit 08560e5

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

86 files changed

+2791
-1622
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,5 @@ coverage/
66
test/encrypted/nodejs-docs-samples.json
77
*.iml
88
.idea/
9-
config.json
9+
config.json
10+
key.json

.travis.yml

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@
1414
sudo: false
1515
language: node_js
1616
node_js:
17-
- "stable"
18-
- "0.12"
17+
- "4"
1918

2019
cache:
2120
directories:
@@ -34,12 +33,6 @@ env:
3433
- GOOGLE_APPLICATION_CREDENTIALS=$TRAVIS_BUILD_DIR/test/encrypted/nodejs-docs-samples.json
3534
- CLOUD_BUCKET=nodejs-docs-samples
3635
- GCLOUD_PROJECT=nodejs-docs-samples
37-
- OAUTH_CLIENT_ID=test-id
38-
- OAUTH_CLIENT_SECRET=test-secret
39-
matrix:
40-
- DATA_BACKEND=datastore
41-
- DATA_BACKEND=mongodb
42-
- DATA_BACKEND=cloudsql
4336

4437
before_install:
4538
- if [ ! -d $HOME/gcloud/google-cloud-sdk ]; then
@@ -57,4 +50,4 @@ before_install:
5750
fi
5851

5952
after_success:
60-
- npm run coveralls
53+
- npm run codecov

1-hello-world/.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
node_modules
2+
*.log
3+
config.json

1-hello-world/app.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,8 @@ if (module === require.main) {
2828
// [START server]
2929
// Start the server
3030
var server = app.listen(process.env.PORT || 8080, function () {
31-
var host = server.address().address;
3231
var port = server.address().port;
33-
34-
console.log('App listening at http://%s:%s', host, port);
32+
console.log('App listening on port %s', port);
3533
});
3634
// [END server]
3735
}

1-hello-world/package.json

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
"start": "node app.js",
99
"monitor": "nodemon app.js",
1010
"deploy": "gcloud preview app deploy app.yaml",
11-
"lint": "jshint --exclude-path=../.gitignore .",
1211
"mocha": "mocha test/index.js -t 30000",
12+
"lint": "semistandard \"**/*.js\"",
1313
"test": "npm run lint && npm run mocha"
1414
},
1515
"author": "Google Inc.",
@@ -28,12 +28,23 @@
2828
}
2929
],
3030
"license": "Apache Version 2.0",
31+
"semistandard": {
32+
"globals": [
33+
"after",
34+
"afterEach",
35+
"before",
36+
"beforeEach",
37+
"describe",
38+
"it"
39+
]
40+
},
3141
"dependencies": {
3242
"express": "^4.13.4"
3343
},
3444
"devDependencies": {
35-
"jshint": "^2.9.1",
3645
"mocha": "^2.4.5",
46+
"nodejs-repo-tools": "git+https://github.com/GoogleCloudPlatform/nodejs-repo-tools.git#21daa823090c43fb667157c8b5b0c3b7f45a8357",
47+
"semistandard": "^7.0.5",
3748
"supertest": "^1.2.0"
3849
},
3950
"engines": {

1-hello-world/test/app.test.js

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,17 @@
1515

1616
var assert = require('assert');
1717
var config = require('./config');
18-
var request = require('supertest');
19-
var utils = require('../../test/utils');
18+
var utils = require('nodejs-repo-tools');
2019

2120
describe('app.js', function () {
22-
it('should run', function (done) {
23-
utils.testLocalApp(config, done);
24-
});
21+
if (!process.env.E2E_TESTS) {
22+
it('should run', function (done) {
23+
utils.testLocalApp(config, done);
24+
});
25+
}
26+
2527
it('should create an express app', function (done) {
26-
request(require('../app'))
28+
utils.getRequest(config)
2729
.get('/')
2830
.expect(200)
2931
.expect(function (response) {

1-hello-world/test/config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ var path = require('path');
1717

1818
module.exports = {
1919
test: '1-hello-world',
20-
path: path.resolve(path.join(__dirname, '../')),
20+
cwd: path.resolve(path.join(__dirname, '../')),
2121
cmd: 'node',
2222
args: ['app.js'],
2323
msg: 'Hello, world!'

1-hello-world/test/index.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,14 @@
1414
'use strict';
1515

1616
var config = require('./config');
17-
var utils = require('../../test/utils');
17+
var utils = require('nodejs-repo-tools');
1818

1919
describe(config.test + '/', function () {
20-
it('should install dependencies', function (done) {
21-
this.timeout(60 * 1000); // Allow 1 minute to test installation
22-
utils.testInstallation(config, done);
23-
});
20+
if (!process.env.E2E_TESTS) {
21+
it('should install dependencies', function (done) {
22+
this.timeout(120 * 1000); // Allow 2 minutes to test installation
23+
utils.testInstallation(config, done);
24+
});
25+
}
2426
require('./app.test');
2527
});

2-structured-data/.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
node_modules
2+
*.log
3+
config.json

2-structured-data/app.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,8 @@ app.use(function (err, req, res, next) {
5050
if (module === require.main) {
5151
// Start the server
5252
var server = app.listen(config.get('PORT'), function () {
53-
var host = server.address().address;
5453
var port = server.address().port;
55-
56-
console.log('App listening at http://%s:%s', host, port);
54+
console.log('App listening on port %s', port);
5755
});
5856
}
5957

0 commit comments

Comments
 (0)