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
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ on:
pull_request:
paths:
- 'handwritten/bigtable/**'
name: conformance
name: bigtable-conformance
jobs:
conformance:
runs-on: ubuntu-latest
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ on:
pull_request:
paths:
- 'handwritten/storage/**'
name: conformance
name: storage-conformance
jobs:
conformance-test:
runs-on: ubuntu-latest
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ import {packNTest} from 'pack-n-play';
import * as assert from 'assert';
import {describe, it} from 'mocha';

describe('ESM package', () => {
describe('ESM package', function () {
this.timeout(120000);
it('should support esm property', () =>
packNTest({
sample: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ import {packNTest} from 'pack-n-play';
import * as assert from 'assert';
import {describe, it} from 'mocha';

describe('leaky tests', () => {
describe('leaky tests', function () {
this.timeout(120000);
it('should fail packing n testing', async () => {
await assert.rejects(
packNTest({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
import {packNTest} from 'pack-n-play';
import {describe, it} from 'mocha';

describe('passing tests', () => {
describe('passing tests', function () {
this.timeout(120000);
it('should pass the test', async () => {
await packNTest({
sample: {
Expand Down
5 changes: 3 additions & 2 deletions core/dev-packages/pack-n-play/test/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ import execa = require('execa');
import {describe, it} from 'mocha';

describe('pack-n-play', () => {
it('should run tests', async () => {
it('should run tests', async function () {
this.timeout(600000); // 10 minutes
const fixturesPath = path.resolve('./test/fixtures');
const dirs = fs
.readdirSync(fixturesPath)
Expand All @@ -29,7 +30,7 @@ describe('pack-n-play', () => {
stdio: 'inherit',
cwd: dir,
};
await execa('npm', ['install'], opts);
await execa('npm', ['install', '--no-audit', '--no-fund'], opts);
await execa('npm', ['link', '../../../'], opts);
await execa('npm', ['test'], opts);
}
Expand Down
22 changes: 17 additions & 5 deletions core/packages/gcp-metadata/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -383,12 +383,24 @@ export async function isAvailable() {
if (err.response && err.response.status === 404) {
return false;
} else {
const errObj = e as any;
const getErrorCode = (err: any): string => {
let target = err;
if (
target instanceof Error &&
target.cause &&
!('code' in target) &&
target.name !== 'AggregateError'
) {
target = target.cause;
}
return target?.code ? target.code.toString() : 'UNKNOWN';
};

const codes =
e instanceof Error && e.name === 'AggregateError'
? (e as any).errors.map((error: any) =>
error.code ? error.code.toString() : 'UNKNOWN',
)
: [err.code ? err.code.toString() : 'UNKNOWN'];
errObj instanceof Error && errObj.name === 'AggregateError'
? (errObj as any).errors.map(getErrorCode)
: [getErrorCode(errObj)];

const isExpected = codes.every((code: string) =>
[
Expand Down
12 changes: 9 additions & 3 deletions core/packages/nodejs-googleapis-common/src/discovery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@

import * as fs from 'fs';
import {Gaxios} from 'gaxios';
import resolve = require('url');
import * as util from 'util';

import {GlobalOptions, ServiceOptions, APIRequestParams} from './api';
Expand Down Expand Up @@ -136,8 +135,15 @@ export class Discovery {
apiDiscoveryUrl: string | {url?: string},
): Promise<EndpointCreator> {
if (typeof apiDiscoveryUrl === 'string') {
const parts = resolve.parse(apiDiscoveryUrl);
if (apiDiscoveryUrl && !parts.protocol) {
let isUrl = false;
try {
const parsed = new URL(apiDiscoveryUrl);
isUrl = parsed.protocol === 'http:' || parsed.protocol === 'https:';
} catch (e) {
// Not a valid URL
}

if (apiDiscoveryUrl && !isUrl) {
this.log('Reading from file ' + apiDiscoveryUrl);
const file = await readFile(apiDiscoveryUrl, {encoding: 'utf8'});
return this.makeEndpoint(JSON.parse(file));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ describe(__filename, () => {
nock.cleanAll();
});
it('should discover an API', async () => {
const discoUrl = 'http://test.local';
const discoUrl = 'http://test.local:80';
const scope = nock(discoUrl)
.get('/')
.replyWithFile(200, './test/fixtures/compute-v1.json', {
Expand All @@ -37,7 +37,7 @@ describe(__filename, () => {
scope.done();
});
it('should discover an API through second weird path', async () => {
const discoUrl = 'http://test.local';
const discoUrl = 'http://test.local:80';
const scope = nock(discoUrl)
.get('/')
.replyWithFile(200, './test/fixtures/compute-v1.json', {
Expand Down
Loading
Loading