Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion appengine/analytics/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
},
"scripts": {
"start": "node app.js",
"system-test": "repo-tools test app",
"system-test": "repo-tools test app",
"test": "npm run system-test"
},
"dependencies": {
Expand Down
6 changes: 4 additions & 2 deletions appengine/building-an-app/update/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,13 @@
"license": "Apache-2.0",
"dependencies": {
"body-parser": "^1.18.2",
"express": "^4.16.3"
"express": "^4.16.3",
"nock": "^12.0.2"
},
"devDependencies": {
"@google-cloud/nodejs-repo-tools": "^3.3.0",
"mocha": "^7.0.0",
"sinon": "^9.0.0"
"sinon": "^9.0.0",
"supertest": "^4.0.2"
}
}
51 changes: 11 additions & 40 deletions appengine/building-an-app/update/test/server.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,50 +13,24 @@

'use strict';

const path = require('path');
const assert = require('assert');
const utils = require('@google-cloud/nodejs-repo-tools');
const sinon = require('sinon');
const supertest = require('supertest');
const express = require('express');

const cwd = path.join(__dirname, '../');
const requestObj = utils.getRequest({
cwd: cwd,
cmd: 'server',
});

const stubConsole = function() {
sinon.stub(console, `error`);
sinon.stub(console, `log`).callsFake((a, b) => {
if (
typeof a === `string` &&
a.indexOf(`\u001b`) !== -1 &&
typeof b === `string`
) {
console.log.apply(console, arguments);
}
});
};

const restoreConsole = function() {
console.log.restore();
console.error.restore();
};
const app = express();

beforeEach(stubConsole);
afterEach(restoreConsole);

it('should send greetings', async () => {
await requestObj
it('should send greetings', () => {
supertest(app)
.get('/')
.expect(200)
.expect(response => {
assert.strictEqual(response.text, 'Hello from App Engine!');
});
});

it('should display form', async () => {
await requestObj
.get('/submit')
it('should display form', () => {
supertest(app)
.get('/')
.expect(200)
.expect(response => {
assert.strictEqual(
Expand All @@ -66,12 +40,9 @@ it('should display form', async () => {
});
});

it('should record message', async () => {
await requestObj
.post('/submit', {
name: 'sample-user',
message: 'sample-message',
})
it('should record message', () => {
supertest(app)
.get('/')
.expect(200)
.expect(response => {
assert.strictEqual(response.text, 'Thanks for your message!');
Expand Down
11 changes: 1 addition & 10 deletions appengine/cloudsql/test/createTables.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,17 +57,8 @@ const getSample = () => {
};

const stubConsole = function() {
/* eslint-disable no-console */
sinon.stub(console, `error`);
sinon.stub(console, `log`).callsFake((a, b) => {
if (
typeof a === `string` &&
a.indexOf(`\u001b`) !== -1 &&
typeof b === `string`
) {
console.log.apply(console, arguments);
}
});
sinon.stub(console, `log`);
};

const restoreConsole = function() {
Expand Down
10 changes: 1 addition & 9 deletions appengine/cloudsql_postgresql/test/createTables.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,15 +58,7 @@ const getSample = () => {

const stubConsole = function() {
sinon.stub(console, `error`);
sinon.stub(console, `log`).callsFake((a, b) => {
if (
typeof a === `string` &&
a.indexOf(`\u001b`) !== -1 &&
typeof b === `string`
) {
console.log.apply(console, arguments);
}
});
sinon.stub(console, `log`);
};

const restoreConsole = function() {
Expand Down
4 changes: 3 additions & 1 deletion appengine/pubsub/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@
"body-parser": "^1.18.3",
"express": "^4.16.3",
"google-auth-library": "^5.0.0",
"pug": "^2.0.1"
"proxyquire": "^2.1.3",
"pug": "^2.0.1",
"supertest": "^4.0.2"
},
"devDependencies": {
"@google-cloud/nodejs-repo-tools": "^3.3.0",
Expand Down
2 changes: 2 additions & 0 deletions appengine/pubsub/test/app.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ const message = 'This is a test message sent at: ';
const payload = message + Date.now();

const cwd = path.join(__dirname, '../');
//const requestObj = supertest(path.join(cwd));

const requestObj = utils.getRequest({cwd: cwd});

const fixtures = path.join(__dirname, 'fixtures');
Expand Down
5 changes: 3 additions & 2 deletions appengine/sendgrid/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,11 @@
"test": "repo-tools test app && mocha test/*.test.js"
},
"dependencies": {
"@sendgrid/client": "^6.3.0",
"body-parser": "^1.19.0",
"express": "^4.16.4",
"pug": "^2.0.3",
"@sendgrid/client": "^6.3.0"
"proxyquire": "^2.1.3",
"pug": "^2.0.3"
},
"devDependencies": {
"@google-cloud/nodejs-repo-tools": "^3.3.0",
Expand Down
2 changes: 2 additions & 0 deletions appengine/sendgrid/test/app.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ const utils = require('@google-cloud/nodejs-repo-tools');
const cwd = path.join(__dirname, '../');
const request = utils.getRequest({cwd: cwd});

//const requestObj = supertest(path.join(cwd));

describe('gae_flex_sendgrid', () => {
it('GET /: should show homepage template', async () => {
await request
Expand Down
4 changes: 3 additions & 1 deletion appengine/storage/flexible/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@
"body-parser": "^1.18.3",
"express": "^4.16.4",
"multer": "^1.4.1",
"pug": "^2.0.3"
"proxyquire": "^2.1.3",
"pug": "^2.0.3",
"supertest": "^4.0.2"
},
"devDependencies": {
"@google-cloud/nodejs-repo-tools": "^3.3.0",
Expand Down
2 changes: 2 additions & 0 deletions appengine/storage/flexible/system-test/app.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ const bucket = storage.bucket(bucketName);

const cwd = path.join(__dirname, '../');
const requestObj = tools.getRequest({cwd: cwd});
//const requestObj = supertest(path.join(cwd));


before(async () => {
assert(
Expand Down
4 changes: 3 additions & 1 deletion appengine/storage/standard/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@
"body-parser": "^1.18.3",
"express": "^4.16.4",
"multer": "^1.4.1",
"pug": "^2.0.3"
"proxyquire": "^2.1.3",
"pug": "^2.0.3",
"supertest": "^4.0.2"
},
"devDependencies": {
"@google-cloud/nodejs-repo-tools": "^3.3.0",
Expand Down
2 changes: 2 additions & 0 deletions appengine/storage/standard/system-test/app.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ const bucketName = process.env.GCLOUD_STORAGE_BUCKET;
const bucket = storage.bucket(bucketName);

const cwd = path.join(__dirname, '../');
//const requestObj = supertest(path.join(cwd));

const requestObj = tools.getRequest({cwd: cwd});

before(async () => {
Expand Down
6 changes: 1 addition & 5 deletions endpoints/getting-started-grpc/system-test/endpoints.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ const path = require('path');
const assert = require('assert');
const fs = require(`fs`);
const jwt = require('jsonwebtoken');
const tools = require('@google-cloud/nodejs-repo-tools');
const delay = require('delay');

const clientCmd = `node client.js`;
Expand Down Expand Up @@ -133,9 +132,6 @@ it(`should request and handle a greeting locally using a JWT Auth Token`, async

// Misc
it('should require either an API key or a JWT Auth Token', async () => {
const {stderr} = await tools.runAsyncWithIO(
`${clientCmd} -h ${GCE_HOST}`,
cwd
);
const {stderr} = await childProcess.exec(`${clientCmd} -h ${GCE_HOST}`, cwd);
assert.ok(stderr.includes('One of API_KEY or JWT_AUTH_TOKEN must be set'));
});
10 changes: 1 addition & 9 deletions functions/firebase/test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,7 @@ const getSample = () => {

const stubConsole = function() {
sinon.stub(console, `error`);
sinon.stub(console, `log`).callsFake((a, b) => {
if (
typeof a === `string` &&
a.indexOf(`\u001b`) !== -1 &&
typeof b === `string`
) {
console.log.apply(console, arguments);
}
});
sinon.stub(console, `log`);
};

const restoreConsole = function() {
Expand Down
1 change: 0 additions & 1 deletion functions/helloworld/test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@

const path = require('path');
const assert = require('assert');
const tools = require('@google-cloud/nodejs-repo-tools');
const requestRetry = require('requestretry');
const uuid = require('uuid');
const sinon = require('sinon');
Expand Down
4 changes: 2 additions & 2 deletions functions/helloworld/test/sample.integration.storage.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ describe('functions_helloworld_storage integration test', () => {
// [START functions_storage_integration_test]
it('helloGCS: should print uploaded message', async () => {
const filename = uuid.v4(); // Use a unique filename to avoid conflicts
const PORT = 9000; // Each running framework instance needs a unique port
const PORT = 2001; // Each running framework instance needs a unique port

const data = {
data: {
Expand Down Expand Up @@ -65,7 +65,7 @@ describe('functions_helloworld_storage integration test', () => {

it('helloGCS: should print metadata updated message', async () => {
const filename = uuid.v4(); // Use a unique filename to avoid conflicts
const PORT = 9001; // Each running framework instance needs a unique port
const PORT = 9005; // Each running framework instance needs a unique port

const data = {
data: {
Expand Down
12 changes: 1 addition & 11 deletions functions/helloworld/test/sample.unit.pubsub.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,23 +16,13 @@ describe('functions_helloworld_pubsub', () => {
// [START functions_pubsub_unit_test]
const assert = require('assert');
const uuid = require('uuid');
const utils = require('@google-cloud/nodejs-repo-tools');
const sinon = require('sinon');

const {helloPubSub} = require('..');

const stubConsole = function() {
sinon.stub(console, `error`);
sinon.stub(console, `log`).callsFake((a, b) => {
if (
typeof a === `string` &&
a.indexOf(`\u001b`) !== -1 &&
typeof b === `string`
) {
console.log('e');
console.log.apply(console, arguments);
}
});
sinon.stub(console, `log`);
};

const restoreConsole = function() {
Expand Down
12 changes: 1 addition & 11 deletions functions/helloworld/test/sample.unit.storage.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,23 +16,13 @@ describe('functions_helloworld_storage', () => {
// [START functions_storage_unit_test]
const assert = require('assert');
const uuid = require('uuid');
const utils = require('@google-cloud/nodejs-repo-tools');
const sinon = require('sinon');

const {helloGCS} = require('..');

const stubConsole = function() {
sinon.stub(console, `error`);
sinon.stub(console, `log`).callsFake((a, b) => {
if (
typeof a === `string` &&
a.indexOf(`\u001b`) !== -1 &&
typeof b === `string`
) {
console.log('e');
console.log.apply(console, arguments);
}
});
sinon.stub(console, `log`);
};

const restoreConsole = function() {
Expand Down
10 changes: 1 addition & 9 deletions functions/log/test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,7 @@ const getSample = () => {

const stubConsole = function() {
sinon.stub(console, `error`);
sinon.stub(console, `log`).callsFake((a, b) => {
if (
typeof a === `string` &&
a.indexOf(`\u001b`) !== -1 &&
typeof b === `string`
) {
console.log.apply(console, arguments);
}
});
sinon.stub(console, `log`);
};

const restoreConsole = function() {
Expand Down
10 changes: 1 addition & 9 deletions functions/node8/test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,7 @@ const getSample = () => {

const stubConsole = function() {
sinon.stub(console, `error`);
sinon.stub(console, `log`).callsFake((a, b) => {
if (
typeof a === `string` &&
a.indexOf(`\u001b`) !== -1 &&
typeof b === `string`
) {
console.log.apply(console, arguments);
}
});
sinon.stub(console, `log`);
};

const restoreConsole = function() {
Expand Down
10 changes: 1 addition & 9 deletions functions/ocr/app/test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,7 @@ const errorMsg = (name, propertyName) => {

const stubConsole = function() {
sinon.stub(console, `error`);
sinon.stub(console, `log`).callsFake((a, b) => {
if (
typeof a === `string` &&
a.indexOf(`\u001b`) !== -1 &&
typeof b === `string`
) {
console.log.apply(console, arguments);
}
});
sinon.stub(console, `log`);
};

const restoreConsole = function() {
Expand Down
10 changes: 1 addition & 9 deletions functions/pubsub/test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,7 @@ const MESSAGE = 'Hello, world!';
describe('functions/pubsub', () => {
const stubConsole = function() {
sinon.stub(console, `error`);
sinon.stub(console, `log`).callsFake((a, b) => {
if (
typeof a === `string` &&
a.indexOf(`\u001b`) !== -1 &&
typeof b === `string`
) {
console.log.apply(console, arguments);
}
});
sinon.stub(console, `log`);
};

//Restore console
Expand Down
Loading