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
11 changes: 9 additions & 2 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,15 @@
"env": {
"mocha": true
},
"parserOptions": {
"sourceType": "module",
"ecmaVersion": 2020
},
"rules": {
"node/no-missing-require": ["off"],
"node/no-unpublished-require": ["off"]
"node/no-missing-import": ["off"],
"node/no-unpublished-require": ["off"],
"node/no-unpublished-import": ["off"],
"node/no-unsupported-features/es-syntax": ["off"]
}
}
}
7 changes: 5 additions & 2 deletions eventarc/audit-storage/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@
"type": "git",
"url": "https://github.com/GoogleCloudPlatform/nodejs-docs-samples.git"
},
"type": "module",
"engines": {
"node": ">= 12.0.0"
"node": ">= 12.2.0"
},
"scripts": {
"start": "node index.js",
Expand All @@ -24,7 +25,9 @@
"express": "^4.16.4"
},
"devDependencies": {
"got": "^11.5.0",
"@types/sinon": "^10.0.13",
"@types/supertest": "^2.0.12",
"got": "^12.0.0",
"mocha": "^10.0.0",
"sinon": "^15.0.0",
"supertest": "^6.0.0"
Expand Down
18 changes: 12 additions & 6 deletions eventarc/audit-storage/test/app.test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2020, Google LLC.
// Copyright 2020 Google LLC
// 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
Expand All @@ -18,16 +18,22 @@

'use strict';

const assert = require('assert');
const path = require('path');
const supertest = require('supertest');
const sinon = require('sinon');
import assert from 'assert';
import path from 'path';
import supertest from 'supertest';
import sinon from 'sinon';
import {createRequire} from 'module';

import {fileURLToPath} from 'url';
import {dirname} from 'path';
const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);

let request;

describe('Unit Tests', () => {
before(() => {
const app = require(path.join(__dirname, '..', 'app'));
const app = createRequire(path.join(__dirname, '..', 'app'));
request = supertest(app);
});

Expand Down
8 changes: 4 additions & 4 deletions eventarc/audit-storage/test/system.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@
// See the License for the specific language governing permissions and
// limitations under the License.

const assert = require('assert');
const got = require('got');
import assert from 'assert';
import got from 'got';

const request = (method, route, base_url) => {
function request(method, route, base_url) {
const {ID_TOKEN} = process.env;
if (!ID_TOKEN) {
throw Error('"ID_TOKEN" environment variable is required.');
Expand All @@ -28,7 +28,7 @@ const request = (method, route, base_url) => {
method: method || 'get',
throwHttpErrors: false,
});
};
}

describe('End-to-End Tests', () => {
const {BASE_URL} = process.env;
Expand Down
7 changes: 5 additions & 2 deletions eventarc/generic/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"name": "cloud-eventarc-generic",
"version": "1.0.0",
"private": true,
"type": "module",
"main": "index.js",
"author": "Google LLC",
"license": "Apache-2.0",
Expand All @@ -10,7 +11,7 @@
"url": "https://github.com/GoogleCloudPlatform/nodejs-docs-samples.git"
},
"engines": {
"node": ">= 12.0.0"
"node": ">= 12.2.0"
},
"scripts": {
"start": "node index.js",
Expand All @@ -21,7 +22,9 @@
"express": "^4.16.4"
},
"devDependencies": {
"got": "^11.5.0",
"@types/sinon": "^10.0.13",
"@types/supertest": "^2.0.12",
"got": "^12.0.0",
"mocha": "^10.0.0",
"sinon": "^15.0.0",
"supertest": "^6.0.0",
Expand Down
16 changes: 11 additions & 5 deletions eventarc/generic/test/app.test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2019, Google LLC.
// Copyright 2019 Google LLC
// 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
Expand All @@ -18,15 +18,21 @@

'use strict';

const assert = require('assert');
const path = require('path');
const supertest = require('supertest');
import assert from 'assert';
import path from 'path';
import supertest from 'supertest';
import {createRequire} from 'module';
import {fileURLToPath} from 'url';
import {dirname} from 'path';

const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);

let request;

describe('Unit Tests', () => {
before(() => {
const app = require(path.join(__dirname, '..', 'app'));
const app = createRequire(path.join(__dirname, '..', 'app'));
request = supertest(app);
});

Expand Down
4 changes: 2 additions & 2 deletions eventarc/generic/test/system.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
// See the License for the specific language governing permissions and
// limitations under the License.

const assert = require('assert');
const got = require('got');
import assert from 'assert';
import got from 'got';

const request = (method, route, base_url) => {
const {ID_TOKEN} = process.env;
Expand Down
7 changes: 5 additions & 2 deletions eventarc/pubsub/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"name": "cloud-eventarc-pubsub",
"version": "1.0.0",
"private": true,
"type": "module",
"description": "Simple Events for Cloud Run – Pub/Sub sample",
"main": "index.js",
"author": "Google LLC",
Expand All @@ -11,7 +12,7 @@
"url": "https://github.com/GoogleCloudPlatform/nodejs-docs-samples.git"
},
"engines": {
"node": ">= 12.0.0"
"node": ">= 12.2.0"
},
"scripts": {
"start": "node index.js",
Expand All @@ -25,7 +26,9 @@
"express": "^4.16.4"
},
"devDependencies": {
"got": "^11.5.0",
"@types/sinon": "^10.0.13",
"@types/supertest": "^2.0.12",
"got": "^12.0.0",
"mocha": "^10.0.0",
"sinon": "^15.0.0",
"supertest": "^6.0.0",
Expand Down
16 changes: 11 additions & 5 deletions eventarc/pubsub/test/app.test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2019, Google LLC.
// Copyright 2019 Google LLC
// 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
Expand All @@ -18,15 +18,21 @@

'use strict';

const assert = require('assert');
const path = require('path');
const supertest = require('supertest');
import assert from 'assert';
import path from 'path';
import supertest from 'supertest';
import {createRequire} from 'module';
import {fileURLToPath} from 'url';
import {dirname} from 'path';

const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);

let request;

describe('Unit Tests', () => {
before(() => {
const app = require(path.join(__dirname, '..', 'app'));
const app = createRequire(path.join(__dirname, '..', 'app'));
request = supertest(app);
});

Expand Down
4 changes: 2 additions & 2 deletions eventarc/pubsub/test/system.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
// See the License for the specific language governing permissions and
// limitations under the License.

const assert = require('assert');
const got = require('got');
import assert from 'assert';
import got from 'got';

const request = (method, route, base_url) => {
const {ID_TOKEN} = process.env;
Expand Down
3 changes: 2 additions & 1 deletion run/hello-broken/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"description": "Broken Cloud Run service for troubleshooting practice",
"version": "1.0.0",
"private": true,
"type": "module",
"main": "index.js",
"scripts": {
"start": "node index.js",
Expand All @@ -19,7 +20,7 @@
},
"devDependencies": {
"google-auth-library": "^8.0.0",
"got": "^11.0.0",
"got": "^12.0.0",
"mocha": "^10.0.0"
}
}
10 changes: 5 additions & 5 deletions run/hello-broken/test/system.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@
// See the License for the specific language governing permissions and
// limitations under the License.

const assert = require('assert');
const request = require('got');
const {execSync} = require('child_process');
const {GoogleAuth} = require('google-auth-library');
import assert from 'assert';
import got from 'got';
import {execSync} from 'child_process';
import {GoogleAuth} from 'google-auth-library';
const auth = new GoogleAuth();

const get = (route, base_url, id_token, retry = 3) => {
return request(new URL(route, base_url.trim()), {
return got(new URL(route, base_url.trim()), {
headers: {
Authorization: `${id_token.trim()}`,
},
Expand Down
5 changes: 3 additions & 2 deletions run/helloworld/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@
"description": "Simple hello world sample in Node",
"version": "1.0.0",
"private": true,
"type": "module",
"main": "index.js",
"scripts": {
"start": "node index.js",
"test": "mocha test/index.test.js --exit",
"system-test": "NAME=Cloud mocha test/system.test.js --timeout=180000"
},
"engines": {
"node": ">= 12.0.0"
"node": ">= 12.2.0"
},
"author": "Google LLC",
"license": "Apache-2.0",
Expand All @@ -19,7 +20,7 @@
},
"devDependencies": {
"google-auth-library": "^8.0.0",
"got": "^11.0.0",
"got": "^12.0.0",
"mocha": "^10.0.0",
"supertest": "^6.0.0"
}
Expand Down
14 changes: 10 additions & 4 deletions run/helloworld/test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,20 @@
// See the License for the specific language governing permissions and
// limitations under the License.

const assert = require('assert');
const path = require('path');
const supertest = require('supertest');
import assert from 'assert';
import path from 'path';
import supertest from 'supertest';
import {createRequire} from 'module';
import {fileURLToPath} from 'url';
import {dirname} from 'path';

const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);

let request;
describe('Unit Tests', () => {
before(() => {
const app = require(path.join(__dirname, '..', 'index'));
const app = createRequire(path.join(__dirname, '..', 'index'));
request = supertest(app);
});

Expand Down
4 changes: 2 additions & 2 deletions run/helloworld/test/system.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

const assert = require('assert');
const {execSync} = require('child_process');
const request = require('got');
import got from 'got';
const {GoogleAuth} = require('google-auth-library');
const auth = new GoogleAuth();

Expand All @@ -23,7 +23,7 @@ const get = (route, base_url) => {
throw Error('"ID_TOKEN" environment variable is required.');
}

return request(new URL(route, base_url.trim()), {
return got(new URL(route, base_url.trim()), {
headers: {
Authorization: `${ID_TOKEN.trim()}`,
},
Expand Down
5 changes: 3 additions & 2 deletions run/idp-sql/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@
"description": "Identity Platform and Cloud SQL integrations sample for Cloud Run.",
"version": "0.0.1",
"private": true,
"type": "module",
"license": "Apache-2.0",
"author": "Google LLC",
"repository": {
"type": "git",
"url": "https://github.com/GoogleCloudPlatform/nodejs-docs-samples.git"
},
"engines": {
"node": ">=12.0.0"
"node": ">=12.2.0"
},
"scripts": {
"start": "node index.js",
Expand All @@ -28,7 +29,7 @@
"winston": "3.8.2"
},
"devDependencies": {
"got": "^11.7.0",
"got": "^12.0.0",
"mocha": "^10.0.0",
"short-uuid": "^4.1.0",
"sinon": "^15.0.0",
Expand Down
16 changes: 11 additions & 5 deletions run/idp-sql/test/app.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,22 @@

'use strict';

const path = require('path');
const assert = require('assert');
const supertest = require('supertest');
const {buildRenderedHtml} = require('../handlebars');
import path from 'path';
import assert from 'assert';
import supertest from 'supertest';
import {createRequire} from 'module';
import {fileURLToPath} from 'url';
import {dirname} from 'path';
import {buildRenderedHtml} from '../handlebars';

const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);

let request;

describe('Unit Tests', () => {
before(async () => {
const app = require(path.join(__dirname, '..', 'app'));
const app = createRequire(path.join(__dirname, '..', 'app'));
request = supertest(app);
});

Expand Down
Loading