Skip to content

Commit

Permalink
ci(appengine): add metadata/standard to testing isolation (#3986)
Browse files Browse the repository at this point in the history
* 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]>
  • Loading branch information
2 people authored and vatsal-vora-crestdata committed Feb 26, 2025
1 parent 09f8492 commit 7a37635
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 8 deletions.
3 changes: 1 addition & 2 deletions .github/config/nodejs-prod.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
".kokoro/",
".prettierignore",
".prettierrc.js",
"cloud-samples-tools", // checked out by GH action in ci-*.yml
"cloud-samples-tools", // checked out by GH action in ci-*.yml
"CODEOWNERS",
"CODE_OF_CONDUCT.md",
"CONTRIBUTING.md",
Expand Down Expand Up @@ -70,7 +70,6 @@
"ai-platform/snippets", // PERMISSION_DENIED: Permission denied: Consumer 'projects/undefined' has been suspended.
"appengine/analytics", // [ERR_REQUIRE_ESM]: require() of ES Module
"appengine/metadata/flexible", // [ERR_REQUIRE_ESM]: require() of ES Module
"appengine/metadata/standard", // [ERR_REQUIRE_ESM]: require() of ES Module
"automl", // (untested) FAILED_PRECONDITION: Google Cloud AutoML Natural Language was retired on March 15, 2024. Please migrate to Vertex AI instead
"cloud-sql/mysql/mysql", // (untested) Error: expected 200 "OK", got 500 "Internal Server Error"
"cloud-sql/mysql/mysql2", // (untested) Error: Cannot find module './connect-connector-with-iam-authn.js'
Expand Down
1 change: 1 addition & 0 deletions appengine/metadata/standard/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"type": "git",
"url": "https://github.com/GoogleCloudPlatform/nodejs-docs-samples.git"
},
"type": "module",
"engines": {
"node": "20.x"
},
Expand Down
7 changes: 4 additions & 3 deletions appengine/metadata/standard/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@

'use strict';

const express = require('express');
const fetch = require('node-fetch');
import express from 'express';
import fetch from 'node-fetch';

const app = express();
app.enable('trust proxy');
Expand Down Expand Up @@ -57,4 +57,5 @@ app.listen(PORT, () => {
console.log(`App listening on port ${PORT}`);
console.log('Press Ctrl+C to quit.');
});
module.exports = app;

export default app;
19 changes: 16 additions & 3 deletions appengine/metadata/standard/test/server.test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,19 @@
const path = require('path');
const supertest = require('supertest');
const app = require(path.join(__dirname, '../', 'server.js'));
// 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
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

import supertest from 'supertest';
import app from '../server.js';

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

0 comments on commit 7a37635

Please sign in to comment.