Skip to content

Commit 5eaff3c

Browse files
glasntiennae
andauthored
ci(appengine): add metadata/standard to testing isolation (#3986)
* ci(appengine): add metadata/standard to testing isolation * rename * update to ESModules * add copyright header for file year * lint * whitespace lint * remove unneeded ci-setup.json --------- Co-authored-by: Jennifer Davis <[email protected]>
1 parent 5569b68 commit 5eaff3c

File tree

4 files changed

+22
-8
lines changed

4 files changed

+22
-8
lines changed

.github/config/nodejs-prod.jsonc

+1-2
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
".kokoro/",
4343
".prettierignore",
4444
".prettierrc.js",
45-
"cloud-samples-tools", // checked out by GH action in ci-*.yml
45+
"cloud-samples-tools", // checked out by GH action in ci-*.yml
4646
"CODEOWNERS",
4747
"CODE_OF_CONDUCT.md",
4848
"CONTRIBUTING.md",
@@ -70,7 +70,6 @@
7070
"ai-platform/snippets", // PERMISSION_DENIED: Permission denied: Consumer 'projects/undefined' has been suspended.
7171
"appengine/analytics", // [ERR_REQUIRE_ESM]: require() of ES Module
7272
"appengine/metadata/flexible", // [ERR_REQUIRE_ESM]: require() of ES Module
73-
"appengine/metadata/standard", // [ERR_REQUIRE_ESM]: require() of ES Module
7473
"automl", // (untested) FAILED_PRECONDITION: Google Cloud AutoML Natural Language was retired on March 15, 2024. Please migrate to Vertex AI instead
7574
"cloud-sql/mysql/mysql", // (untested) Error: expected 200 "OK", got 500 "Internal Server Error"
7675
"cloud-sql/mysql/mysql2", // (untested) Error: Cannot find module './connect-connector-with-iam-authn.js'

appengine/metadata/standard/package.json

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
"type": "git",
1010
"url": "https://github.com/GoogleCloudPlatform/nodejs-docs-samples.git"
1111
},
12+
"type": "module",
1213
"engines": {
1314
"node": "20.x"
1415
},

appengine/metadata/standard/server.js

+4-3
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414

1515
'use strict';
1616

17-
const express = require('express');
18-
const fetch = require('node-fetch');
17+
import express from 'express';
18+
import fetch from 'node-fetch';
1919

2020
const app = express();
2121
app.enable('trust proxy');
@@ -57,4 +57,5 @@ app.listen(PORT, () => {
5757
console.log(`App listening on port ${PORT}`);
5858
console.log('Press Ctrl+C to quit.');
5959
});
60-
module.exports = app;
60+
61+
export default app;

appengine/metadata/standard/test/server.test.js

+16-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,19 @@
1-
const path = require('path');
2-
const supertest = require('supertest');
3-
const app = require(path.join(__dirname, '../', 'server.js'));
1+
// Copyright 2020 Google LLC
2+
//
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+
15+
import supertest from 'supertest';
16+
import app from '../server.js';
417

518
it('should be listening', async () => {
619
await supertest(app).get('/').expect(200);

0 commit comments

Comments
 (0)