diff --git a/core/common/package.json b/core/common/package.json index 74ee2c5e9136..41610c02df42 100644 --- a/core/common/package.json +++ b/core/common/package.json @@ -20,7 +20,7 @@ ], "scripts": { "docs": "jsdoc -c .jsdoc.js", - "test": "node ../../bin/run-test.cjs --proxyquire-shim build/test", + "test": "node ../../bin/run-test.cjs build/test", "prepare": "npm run compile", "pretest": "npm run compile", "compile": "tsc -p .", @@ -57,6 +57,7 @@ "@types/tmp": "^0.2.6", "c8": "^10.1.3", "codecov": "^3.8.3", + "google-test-utils": "^0.4.0", "gts": "^6.0.2", "jsdoc": "^4.0.4", "jsdoc-fresh": "^6.1.0", diff --git a/core/common/test/service-object.ts b/core/common/test/service-object.ts index 1d3ed35a5fee..a17038302bfa 100644 --- a/core/common/test/service-object.ts +++ b/core/common/test/service-object.ts @@ -20,7 +20,8 @@ import { import * as assert from 'assert'; import {describe, it, beforeEach, afterEach} from 'mocha'; import * as extend from 'extend'; -import * as proxyquire from 'proxyquire'; +import {proxyquire} from 'google-test-utils'; +// eslint-disable-next-line import/namespace import * as r from 'teeny-request'; import * as sinon from 'sinon'; diff --git a/core/common/test/service.ts b/core/common/test/service.ts index 0ed74ade752f..11deb95258c8 100644 --- a/core/common/test/service.ts +++ b/core/common/test/service.ts @@ -15,7 +15,7 @@ import * as assert from 'assert'; import {describe, it, before, beforeEach, after} from 'mocha'; import * as extend from 'extend'; -import * as proxyquire from 'proxyquire'; +import {proxyquire} from 'google-test-utils'; import {Request} from 'teeny-request'; import {AuthClient, GoogleAuth, OAuth2Client} from 'google-auth-library'; diff --git a/core/common/test/util.ts b/core/common/test/util.ts index 5148cc40dce2..cecdf8a35617 100644 --- a/core/common/test/util.ts +++ b/core/common/test/util.ts @@ -26,7 +26,7 @@ import { OAuth2Client, } from 'google-auth-library'; import * as nock from 'nock'; -import * as proxyquire from 'proxyquire'; +import {proxyquire} from 'google-test-utils'; import * as retryRequest from 'retry-request'; import * as sinon from 'sinon'; import * as stream from 'stream'; diff --git a/handwritten/bigquery/package.json b/handwritten/bigquery/package.json index 9161e77ba83d..e6198e3cfdd0 100644 --- a/handwritten/bigquery/package.json +++ b/handwritten/bigquery/package.json @@ -36,7 +36,7 @@ "docs": "jsdoc -c .jsdoc.js", "lint": "gts check", "samples-test": "cd samples/ && pnpm link ../ && pnpm test && cd ../", - "test": "node ../../bin/run-test.cjs --proxyquire-shim build/test", + "test": "node ../../bin/run-test.cjs build/test", "system-test": "node ../../bin/run-test.cjs build/system-test --timeout 600000", "presystem-test": "pnpm run compile", "clean": "gts clean", @@ -91,6 +91,7 @@ "codecov": "^3.8.3", "discovery-tsd": "^0.3.0", "eslint-plugin-prettier": "^5.2.6", + "google-test-utils": "^0.4.0", "gts": "^6.0.2", "jsdoc": "^4.0.4", "jsdoc-fresh": "^6.1.0", diff --git a/handwritten/bigquery/system-test/arrow.ts b/handwritten/bigquery/system-test/arrow.ts index 2781172b1062..b06d4dc36dd8 100644 --- a/handwritten/bigquery/system-test/arrow.ts +++ b/handwritten/bigquery/system-test/arrow.ts @@ -562,7 +562,8 @@ describe('Arrow Query Results', () => { it('should raise the same error as query() when a jobs.insert query fails during execution', async () => { const failingQuery = { - query: 'SELECT 1 / 0', + query: + 'DECLARE n INT64 DEFAULT 50; SELECT 1 / (x - 50) FROM UNNEST(GENERATE_ARRAY(1, n)) AS x ORDER BY x;', jobTimeoutMs: 60000, useQueryCache: false, }; diff --git a/handwritten/bigquery/test/bigquery.ts b/handwritten/bigquery/test/bigquery.ts index 39f837c3bcfa..13ebb0219b32 100644 --- a/handwritten/bigquery/test/bigquery.ts +++ b/handwritten/bigquery/test/bigquery.ts @@ -24,7 +24,7 @@ import * as assert from 'assert'; import {describe, it, after, afterEach, before, beforeEach} from 'mocha'; import * as Big from 'big.js'; import * as extend from 'extend'; -import * as proxyquire from 'proxyquire'; +import {proxyquire} from 'google-test-utils'; import * as sinon from 'sinon'; import * as crypto from 'crypto'; diff --git a/handwritten/bigquery/test/dataset.ts b/handwritten/bigquery/test/dataset.ts index 26bb3ff8a831..d369c322179c 100644 --- a/handwritten/bigquery/test/dataset.ts +++ b/handwritten/bigquery/test/dataset.ts @@ -22,7 +22,7 @@ import * as pfy from '@google-cloud/promisify'; import * as assert from 'assert'; import {describe, it, before, beforeEach} from 'mocha'; import * as extend from 'extend'; -import * as proxyquire from 'proxyquire'; +import {proxyquire} from 'google-test-utils'; import * as _root from '../src'; import {toArray} from '../src/util'; diff --git a/handwritten/bigquery/test/job.ts b/handwritten/bigquery/test/job.ts index afba50a3fc7a..9dcafc9f7ac5 100644 --- a/handwritten/bigquery/test/job.ts +++ b/handwritten/bigquery/test/job.ts @@ -16,7 +16,7 @@ import {DecorateRequestOptions, util} from '@google-cloud/common'; import * as pfy from '@google-cloud/promisify'; import * as assert from 'assert'; import {describe, it, beforeEach, afterEach, before} from 'mocha'; -import * as proxyquire from 'proxyquire'; +import {proxyquire} from 'google-test-utils'; import * as sinon from 'sinon'; import {BigQuery} from '../src/bigquery'; diff --git a/handwritten/bigquery/test/model.ts b/handwritten/bigquery/test/model.ts index 49c59a5cec4b..895afea43b40 100644 --- a/handwritten/bigquery/test/model.ts +++ b/handwritten/bigquery/test/model.ts @@ -15,7 +15,7 @@ import * as assert from 'assert'; import {describe, it, before, beforeEach, afterEach} from 'mocha'; import * as sinon from 'sinon'; -import * as proxyquire from 'proxyquire'; +import {proxyquire} from 'google-test-utils'; import * as pfy from '@google-cloud/promisify'; import {EventEmitter} from 'events'; import {JobOptions} from '../src/job'; diff --git a/handwritten/bigquery/test/routine.ts b/handwritten/bigquery/test/routine.ts index d1cdb0966ac4..f550f2a3aecf 100644 --- a/handwritten/bigquery/test/routine.ts +++ b/handwritten/bigquery/test/routine.ts @@ -17,7 +17,7 @@ import * as pfy from '@google-cloud/promisify'; import * as assert from 'assert'; import {describe, it, before, beforeEach} from 'mocha'; import * as extend from 'extend'; -import * as proxyquire from 'proxyquire'; +import {proxyquire} from 'google-test-utils'; import * as _root from '../src'; diff --git a/handwritten/bigquery/test/rowQueue.ts b/handwritten/bigquery/test/rowQueue.ts index f53dbf011485..bde9198edcc0 100644 --- a/handwritten/bigquery/test/rowQueue.ts +++ b/handwritten/bigquery/test/rowQueue.ts @@ -16,7 +16,7 @@ import {util} from '@google-cloud/common'; import * as assert from 'assert'; import {describe, it, before, beforeEach, afterEach} from 'mocha'; import {Duplex, Stream} from 'stream'; -import * as proxyquire from 'proxyquire'; +import {proxyquire} from 'google-test-utils'; import * as sinon from 'sinon'; import * as q from '../src/rowQueue'; import * as t from '../src/table'; diff --git a/handwritten/bigquery/test/table.ts b/handwritten/bigquery/test/table.ts index f3e59d7f3d9a..eb78c7f00d10 100644 --- a/handwritten/bigquery/test/table.ts +++ b/handwritten/bigquery/test/table.ts @@ -26,7 +26,7 @@ import {describe, it, afterEach, beforeEach, before, after} from 'mocha'; import * as Big from 'big.js'; import {EventEmitter} from 'events'; import * as extend from 'extend'; -import * as proxyquire from 'proxyquire'; +import {proxyquire} from 'google-test-utils'; import * as sinon from 'sinon'; import * as stream from 'stream'; import * as crypto from 'crypto'; diff --git a/handwritten/bigtable/package.json b/handwritten/bigtable/package.json index fd1916d18393..fe0f387d664b 100644 --- a/handwritten/bigtable/package.json +++ b/handwritten/bigtable/package.json @@ -42,7 +42,7 @@ "presystem-test": "pnpm run compile", "system-test": "node ../../bin/run-test.cjs build/system-test --timeout 600000 --retries 3", "pretest": "pnpm run compile", - "test": "node ../../bin/run-test.cjs --proxyquire-shim build/test", + "test": "node ../../bin/run-test.cjs build/test", "test:snap": "SNAPSHOT_UPDATE=1 pnpm test", "testproxy": "pnpm run compile && node build/testproxy/index.js", "clean": "gts clean", @@ -93,6 +93,7 @@ "c8": "^10.1.3", "codecov": "^3.8.3", "gapic-tools": "^2.2.0", + "google-test-utils": "^0.4.0", "gts": "^6.0.2", "jsdoc": "^4.0.4", "jsdoc-fresh": "^6.1.0", diff --git a/handwritten/bigtable/system-test/client-side-metrics-all-methods.ts b/handwritten/bigtable/system-test/client-side-metrics-all-methods.ts index b3d330e4db88..5506958e4d60 100644 --- a/handwritten/bigtable/system-test/client-side-metrics-all-methods.ts +++ b/handwritten/bigtable/system-test/client-side-metrics-all-methods.ts @@ -21,7 +21,7 @@ import { import {ResourceMetrics} from '@opentelemetry/sdk-metrics'; import * as assert from 'assert'; import {GCPMetricsHandler} from '../src/client-side-metrics/gcp-metrics-handler'; -import * as proxyquire from 'proxyquire'; +import {proxyquire} from 'google-test-utils'; import {Bigtable, RawFilter} from '../src'; import {Mutation} from '../src/mutation'; import {Row} from '../src/row'; diff --git a/handwritten/bigtable/system-test/client-side-metrics.ts b/handwritten/bigtable/system-test/client-side-metrics.ts index 4013cb7d0a75..58b5c3ce49af 100644 --- a/handwritten/bigtable/system-test/client-side-metrics.ts +++ b/handwritten/bigtable/system-test/client-side-metrics.ts @@ -21,7 +21,7 @@ import { import {ResourceMetrics} from '@opentelemetry/sdk-metrics'; import * as assert from 'assert'; import {GCPMetricsHandler} from '../src/client-side-metrics/gcp-metrics-handler'; -import * as proxyquire from 'proxyquire'; +import {proxyquire} from 'google-test-utils'; import {Bigtable, BigtableOptions} from '../src'; import {Row} from '../src/row'; import { diff --git a/handwritten/bigtable/system-test/gcp-metrics-handler.ts b/handwritten/bigtable/system-test/gcp-metrics-handler.ts index 2608d6e191b1..a70b449a562c 100644 --- a/handwritten/bigtable/system-test/gcp-metrics-handler.ts +++ b/handwritten/bigtable/system-test/gcp-metrics-handler.ts @@ -26,7 +26,7 @@ import {Bigtable} from '../src'; import {ResourceMetrics} from '@opentelemetry/sdk-metrics'; import * as assert from 'assert'; import {ClientOptions} from 'google-gax'; -import * as proxyquire from 'proxyquire'; +import {proxyquire} from 'google-test-utils'; function getHandler(Exporter: typeof CloudMonitoringExporter) { const FakeCGPMetricsHandler = proxyquire( diff --git a/handwritten/bigtable/system-test/read-rows.ts b/handwritten/bigtable/system-test/read-rows.ts index 15ac57a41298..454f743de83c 100644 --- a/handwritten/bigtable/system-test/read-rows.ts +++ b/handwritten/bigtable/system-test/read-rows.ts @@ -26,7 +26,7 @@ import {EventEmitter} from 'events'; import {Test} from './testTypes'; import {ServiceError, GrpcClient, GoogleError, CallOptions} from 'google-gax'; import {PassThrough} from 'stream'; -import * as proxyquire from 'proxyquire'; +import {proxyquire} from 'google-test-utils'; import {TabularApiSurface} from '../src/tabular-api-surface'; import * as mocha from 'mocha'; import {generateId} from './common'; @@ -141,7 +141,10 @@ describe('Bigtable/Table', () => { 'An error should have been thrown because the client is closed', ); } catch (err: any) { - assert.strictEqual(err.message, 'The client has already been closed.'); + assert.strictEqual( + err.message, + 'The client has already been closed.', + ); } } finally { const bigtableSecondClient = new Bigtable(); diff --git a/handwritten/bigtable/test/app-profile.ts b/handwritten/bigtable/test/app-profile.ts index 581c46f98065..3ebd6ec679c7 100644 --- a/handwritten/bigtable/test/app-profile.ts +++ b/handwritten/bigtable/test/app-profile.ts @@ -15,7 +15,7 @@ import * as promisify from '@google-cloud/promisify'; import * as assert from 'assert'; import {describe, it, before, beforeEach} from 'mocha'; -import * as proxyquire from 'proxyquire'; +import {proxyquire} from 'google-test-utils'; import {CallOptions} from 'google-gax'; let promisified = false; diff --git a/handwritten/bigtable/test/backup.ts b/handwritten/bigtable/test/backup.ts index 915bcde6bad2..779747a32e2d 100644 --- a/handwritten/bigtable/test/backup.ts +++ b/handwritten/bigtable/test/backup.ts @@ -16,7 +16,7 @@ import {PreciseDate} from '@google-cloud/precise-date'; import * as promisify from '@google-cloud/promisify'; import * as assert from 'assert'; import {before, beforeEach, describe, it, afterEach} from 'mocha'; -import * as proxyquire from 'proxyquire'; +import {proxyquire} from 'google-test-utils'; import * as pumpify from 'pumpify'; import {ServiceError} from 'google-gax'; diff --git a/handwritten/bigtable/test/base64keymap.ts b/handwritten/bigtable/test/base64keymap.ts index 527319240f45..d423bdad15be 100644 --- a/handwritten/bigtable/test/base64keymap.ts +++ b/handwritten/bigtable/test/base64keymap.ts @@ -15,7 +15,6 @@ import * as assert from 'assert'; import {describe, it, before, beforeEach, afterEach} from 'mocha'; import Long = require('long'); -import * as proxyquire from 'proxyquire'; import * as sn from 'sinon'; import {RowStateEnum} from '../src/chunktransformer.js'; diff --git a/handwritten/bigtable/test/chunktransformer.ts b/handwritten/bigtable/test/chunktransformer.ts index 88e0e313707a..cac31179cb03 100644 --- a/handwritten/bigtable/test/chunktransformer.ts +++ b/handwritten/bigtable/test/chunktransformer.ts @@ -15,7 +15,7 @@ import * as assert from 'assert'; import {describe, it, before, beforeEach, afterEach} from 'mocha'; import Long = require('long'); -import * as proxyquire from 'proxyquire'; +import {proxyquire} from 'google-test-utils'; import * as sn from 'sinon'; import {RowStateEnum} from '../src/chunktransformer.js'; diff --git a/handwritten/bigtable/test/cluster.ts b/handwritten/bigtable/test/cluster.ts index a1c963cd22f9..a2144ef10318 100644 --- a/handwritten/bigtable/test/cluster.ts +++ b/handwritten/bigtable/test/cluster.ts @@ -15,7 +15,7 @@ import * as promisify from '@google-cloud/promisify'; import * as assert from 'assert'; import {before, beforeEach, describe, it} from 'mocha'; -import * as proxyquire from 'proxyquire'; +import {proxyquire} from 'google-test-utils'; import {PassThrough, Readable} from 'stream'; import {CallOptions} from 'google-gax'; import {PreciseDate} from '@google-cloud/precise-date'; diff --git a/handwritten/bigtable/test/executequery.ts b/handwritten/bigtable/test/executequery.ts index 4d0ea37f205b..ea6168445aed 100644 --- a/handwritten/bigtable/test/executequery.ts +++ b/handwritten/bigtable/test/executequery.ts @@ -15,7 +15,7 @@ import * as promisify from '@google-cloud/promisify'; import * as assert from 'assert'; import {before, beforeEach, afterEach, describe, it} from 'mocha'; import * as sinon from 'sinon'; -import * as proxyquire from 'proxyquire'; +import {proxyquire} from 'google-test-utils'; import {grpc} from 'google-gax'; import * as inst from '../src/instance'; import {Bigtable} from '../src'; diff --git a/handwritten/bigtable/test/family.ts b/handwritten/bigtable/test/family.ts index 4d6b0babc4e2..a4661ca0a57a 100644 --- a/handwritten/bigtable/test/family.ts +++ b/handwritten/bigtable/test/family.ts @@ -15,7 +15,7 @@ import * as promisify from '@google-cloud/promisify'; import * as assert from 'assert'; import {before, beforeEach, afterEach, describe, it} from 'mocha'; -import * as proxyquire from 'proxyquire'; +import {proxyquire} from 'google-test-utils'; import * as sinon from 'sinon'; import {protos} from '@google-cloud/bigtable-api'; import google = protos.google; diff --git a/handwritten/bigtable/test/filter.ts b/handwritten/bigtable/test/filter.ts index d2dc9fbaed7d..e90d445058d2 100644 --- a/handwritten/bigtable/test/filter.ts +++ b/handwritten/bigtable/test/filter.ts @@ -14,7 +14,7 @@ import * as assert from 'assert'; import {afterEach, before, beforeEach, describe, it} from 'mocha'; -import * as proxyquire from 'proxyquire'; +import {proxyquire} from 'google-test-utils'; import * as sinon from 'sinon'; import * as fr from '../src/filter'; import {Row} from '../src/row'; diff --git a/handwritten/bigtable/test/index.ts b/handwritten/bigtable/test/index.ts index 361d2527a300..5345ea6dfa0b 100644 --- a/handwritten/bigtable/test/index.ts +++ b/handwritten/bigtable/test/index.ts @@ -17,7 +17,7 @@ import * as promisify from '@google-cloud/promisify'; import * as assert from 'assert'; import {afterEach, before, beforeEach, describe, it} from 'mocha'; import * as gax from 'google-gax'; -import * as proxyquire from 'proxyquire'; +import {proxyquire} from 'google-test-utils'; import * as sn from 'sinon'; import {Cluster} from '../src/cluster.js'; @@ -1216,6 +1216,7 @@ describe('Bigtable', () => { }); describe('close', () => { it('should have failed request after close is called', done => { + // eslint-disable-next-line promise/catch-or-return, promise/always-return bigtable.close().then(() => { bigtable.getInstances((err: Error) => { if (err) { diff --git a/handwritten/bigtable/test/instance.ts b/handwritten/bigtable/test/instance.ts index 47798885b905..e0431a697ae2 100644 --- a/handwritten/bigtable/test/instance.ts +++ b/handwritten/bigtable/test/instance.ts @@ -16,7 +16,7 @@ import * as promisify from '@google-cloud/promisify'; import * as assert from 'assert'; import {before, beforeEach, afterEach, describe, it} from 'mocha'; import * as sinon from 'sinon'; -import * as proxyquire from 'proxyquire'; +import {proxyquire} from 'google-test-utils'; import {ServiceError} from 'google-gax'; import * as snapshot from 'snap-shot-it'; import {Readable} from 'stream'; diff --git a/handwritten/bigtable/test/metric-service-client-credentials.ts b/handwritten/bigtable/test/metric-service-client-credentials.ts index b05caa470f61..ee563ea76e11 100644 --- a/handwritten/bigtable/test/metric-service-client-credentials.ts +++ b/handwritten/bigtable/test/metric-service-client-credentials.ts @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -import * as proxyquire from 'proxyquire'; +import {proxyquire} from 'google-test-utils'; import {ClientOptions, grpc} from 'google-gax'; import * as assert from 'assert'; import {MetricServiceClient} from '@google-cloud/monitoring'; diff --git a/handwritten/bigtable/test/metrics-collector/gcp-metrics-handler.ts b/handwritten/bigtable/test/metrics-collector/gcp-metrics-handler.ts index 6f54951b5551..8c726b111cfa 100644 --- a/handwritten/bigtable/test/metrics-collector/gcp-metrics-handler.ts +++ b/handwritten/bigtable/test/metrics-collector/gcp-metrics-handler.ts @@ -30,7 +30,7 @@ import { } from '../../test-common/expected-otel-export-input'; import * as assert from 'assert'; import {replaceTimestamps} from '../../test-common/replace-timestamps'; -import * as proxyquire from 'proxyquire'; +import {proxyquire} from 'google-test-utils'; /** * Cleans a ResourceMetrics object by replacing client UUIDs with a placeholder. diff --git a/handwritten/bigtable/test/metrics-collector/metrics-collector.ts b/handwritten/bigtable/test/metrics-collector/metrics-collector.ts index b63bd2b0ba51..92dce755cbcb 100644 --- a/handwritten/bigtable/test/metrics-collector/metrics-collector.ts +++ b/handwritten/bigtable/test/metrics-collector/metrics-collector.ts @@ -23,7 +23,7 @@ import { import {grpc} from 'google-gax'; import {expectedRequestsHandled} from '../../test-common/metrics-handler-fixture'; import * as gax from 'google-gax'; -import * as proxyquire from 'proxyquire'; +import {proxyquire} from 'google-test-utils'; import {GCPMetricsHandler} from '../../src/client-side-metrics/gcp-metrics-handler'; import {getProtoPath} from '../../src/utils/protos'; const protoPath = getProtoPath('google/bigtable/v2/response_params.proto'); diff --git a/handwritten/bigtable/test/row.ts b/handwritten/bigtable/test/row.ts index 155edc311dfd..91d6a2bed82b 100644 --- a/handwritten/bigtable/test/row.ts +++ b/handwritten/bigtable/test/row.ts @@ -15,7 +15,7 @@ import * as promisify from '@google-cloud/promisify'; import * as assert from 'assert'; import {afterEach, beforeEach, describe, it} from 'mocha'; -import * as proxyquire from 'proxyquire'; +import {proxyquire} from 'google-test-utils'; import * as sinon from 'sinon'; import {Mutation} from '../src/mutation.js'; import '../src/table'; diff --git a/handwritten/bigtable/test/table.ts b/handwritten/bigtable/test/table.ts index c403afda3e4e..d818b3704830 100644 --- a/handwritten/bigtable/test/table.ts +++ b/handwritten/bigtable/test/table.ts @@ -15,7 +15,7 @@ import * as promisify from '@google-cloud/promisify'; import * as assert from 'assert'; import {afterEach, before, beforeEach, describe, it} from 'mocha'; -import * as proxyquire from 'proxyquire'; +import {proxyquire} from 'google-test-utils'; import * as pumpify from 'pumpify'; import * as sinon from 'sinon'; import {PassThrough, Writable, Duplex} from 'stream'; diff --git a/handwritten/datastore/package.json b/handwritten/datastore/package.json index f137dfdeff70..1e108786076a 100644 --- a/handwritten/datastore/package.json +++ b/handwritten/datastore/package.json @@ -38,7 +38,7 @@ "presystem-test": "npm run compile", "system-test": "node ../../bin/run-test.cjs build/system-test --timeout 600000", "pretest": "npm run compile", - "test": "node ../../bin/run-test.cjs --proxyquire-shim build/test", + "test": "node ../../bin/run-test.cjs build/test", "precompile": "gts clean" }, "dependencies": { @@ -68,6 +68,7 @@ "async": "^3.2.6", "c8": "^10.1.3", "gapic-tools": "^2.2.0", + "google-test-utils": "^0.4.0", "gts": "^6.0.2", "js-yaml": "^4.1.0", "jsdoc": "^4.0.4", diff --git a/handwritten/datastore/system-test/transaction-spy.ts b/handwritten/datastore/system-test/transaction-spy.ts index 23ea7a69524c..415492f8a50d 100644 --- a/handwritten/datastore/system-test/transaction-spy.ts +++ b/handwritten/datastore/system-test/transaction-spy.ts @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -import * as proxyquire from 'proxyquire'; +import {proxyquire} from 'google-test-utils'; import {DatastoreRequest} from '../src'; import {RequestCallback, RequestConfig} from '../src/request'; diff --git a/handwritten/datastore/test/gapic-mocks/client-initialization-testing.ts b/handwritten/datastore/test/gapic-mocks/client-initialization-testing.ts index a3a16ef7dc30..8a978d916fd9 100644 --- a/handwritten/datastore/test/gapic-mocks/client-initialization-testing.ts +++ b/handwritten/datastore/test/gapic-mocks/client-initialization-testing.ts @@ -21,7 +21,7 @@ import { DatastoreOptions, } from '../../src'; import * as assert from 'assert'; -import * as proxyquire from 'proxyquire'; +import {proxyquire} from 'google-test-utils'; import {Callback, CallOptions} from 'google-gax'; import * as protos from '../../src/protos'; import * as ds from '../../src'; diff --git a/handwritten/datastore/test/index-class.ts b/handwritten/datastore/test/index-class.ts index 3754e4672748..db7b21339846 100644 --- a/handwritten/datastore/test/index-class.ts +++ b/handwritten/datastore/test/index-class.ts @@ -15,7 +15,7 @@ import * as promisify from '@google-cloud/promisify'; import * as assert from 'assert'; import {before, beforeEach, describe, it} from 'mocha'; -import * as proxyquire from 'proxyquire'; +import {proxyquire} from 'google-test-utils'; import * as ds from '../src'; diff --git a/handwritten/datastore/test/index.ts b/handwritten/datastore/test/index.ts index 03fedde213ce..9ca046a1f99b 100644 --- a/handwritten/datastore/test/index.ts +++ b/handwritten/datastore/test/index.ts @@ -15,7 +15,7 @@ import * as assert from 'assert'; import {before, beforeEach, after, afterEach, describe, it} from 'mocha'; import * as gax from 'google-gax'; -import * as proxyquire from 'proxyquire'; +import {proxyquire} from 'google-test-utils'; import {PassThrough, Readable} from 'stream'; import * as ds from '../src'; diff --git a/handwritten/datastore/test/request.ts b/handwritten/datastore/test/request.ts index 97366be73bbe..c90f71367aea 100644 --- a/handwritten/datastore/test/request.ts +++ b/handwritten/datastore/test/request.ts @@ -18,7 +18,7 @@ import {after, afterEach, before, beforeEach, describe, it} from 'mocha'; import * as extend from 'extend'; import * as gax from 'google-gax'; import * as is from 'is'; -import * as proxyquire from 'proxyquire'; +import {proxyquire} from 'google-test-utils'; import * as sinon from 'sinon'; import {PassThrough, Transform} from 'stream'; diff --git a/handwritten/datastore/test/transaction.ts b/handwritten/datastore/test/transaction.ts index 36366c0d7e02..a69f3f84588c 100644 --- a/handwritten/datastore/test/transaction.ts +++ b/handwritten/datastore/test/transaction.ts @@ -16,7 +16,7 @@ import * as pfy from '@google-cloud/promisify'; import arrify = require('arrify'); import * as assert from 'assert'; import {afterEach, beforeEach, before, describe, it} from 'mocha'; -import * as proxyquire from 'proxyquire'; +import {proxyquire} from 'google-test-utils'; import { Datastore, DatastoreOptions, diff --git a/handwritten/google-cloud-dns/package.json b/handwritten/google-cloud-dns/package.json index 3e706c9f109e..cb935fc534ed 100644 --- a/handwritten/google-cloud-dns/package.json +++ b/handwritten/google-cloud-dns/package.json @@ -33,7 +33,7 @@ "scripts": { "docs": "jsdoc -c .jsdoc.js", "lint": "gts check", - "test": "node ../../bin/run-test.cjs --proxyquire-shim build/test", + "test": "node ../../bin/run-test.cjs build/test", "samples-test": "pnpm run compile && cd samples/ && pnpm link ../ && pnpm i && pnpm test", "presystem-test": "pnpm run compile", "system-test": "pnpm run compile && node ../../bin/run-test.cjs build/system-test", @@ -64,6 +64,7 @@ "@types/tmp": "^0.2.6", "c8": "^10.1.3", "codecov": "^3.8.3", + "google-test-utils": "^0.4.0", "gts": "^6.0.2", "jsdoc": "^4.0.4", "jsdoc-fresh": "^6.1.0", diff --git a/handwritten/google-cloud-dns/test/change.ts b/handwritten/google-cloud-dns/test/change.ts index 4d37cfd21cd6..197685947841 100644 --- a/handwritten/google-cloud-dns/test/change.ts +++ b/handwritten/google-cloud-dns/test/change.ts @@ -20,7 +20,7 @@ import { import * as promisify from '@google-cloud/promisify'; import * as assert from 'assert'; import {describe, it, before, beforeEach} from 'mocha'; -import * as proxyquire from 'proxyquire'; +import {proxyquire} from 'google-test-utils'; import {Change} from '../src/change'; let promisified = false; @@ -119,7 +119,7 @@ describe('Change', () => { assert.strictEqual(change, null); assert.strictEqual(apiResponse_, apiResponse); done(); - } + }, ); }); }); @@ -145,7 +145,7 @@ describe('Change', () => { assert.strictEqual(change_, change); assert.strictEqual(apiResponse_, apiResponse); done(); - } + }, ); }); diff --git a/handwritten/google-cloud-dns/test/index.ts b/handwritten/google-cloud-dns/test/index.ts index 0c3fd27da05e..a3ef8499b7ac 100644 --- a/handwritten/google-cloud-dns/test/index.ts +++ b/handwritten/google-cloud-dns/test/index.ts @@ -22,7 +22,7 @@ import * as promisify from '@google-cloud/promisify'; import arrify = require('arrify'); import * as assert from 'assert'; import {describe, it, before, beforeEach} from 'mocha'; -import * as proxyquire from 'proxyquire'; +import {proxyquire} from 'google-test-utils'; import {CoreOptions, OptionsWithUri, Response} from 'request'; import {Zone} from '../src'; @@ -135,7 +135,7 @@ describe('DNS', () => { assert.deepStrictEqual( calledWith.packageJson, // eslint-disable-next-line @typescript-eslint/no-var-requires - require('../../package.json') + require('../../package.json'), ); }); @@ -226,7 +226,7 @@ describe('DNS', () => { assert.strictEqual(zone, null); assert.strictEqual(apiResponse_, apiResponse); done(); - } + }, ); }); }); @@ -265,7 +265,7 @@ describe('DNS', () => { assert.strictEqual(apiResponse_, apiResponse); done(); - } + }, ); }); @@ -318,7 +318,7 @@ describe('DNS', () => { err: Error, zones: Zone[], nextQuery: {}, - apiResponse_: Response + apiResponse_: Response, ) => { assert.strictEqual(err, error); assert.strictEqual(zones, null); @@ -326,7 +326,7 @@ describe('DNS', () => { assert.strictEqual(apiResponse_, apiResponse); done(); - } + }, ); }); }); @@ -377,7 +377,7 @@ describe('DNS', () => { nextQuery, Object.assign({}, query, { pageToken: apiResponseWithNextPageToken.nextPageToken, - }) + }), ); done(); @@ -391,7 +391,7 @@ describe('DNS', () => { err: Error, zones: Zone[], nextQuery: {}, - apiResponse_: Response + apiResponse_: Response, ) => { assert.ifError(err); assert.strictEqual(zones[0], zone); @@ -399,7 +399,7 @@ describe('DNS', () => { assert.strictEqual(apiResponse_, apiResponse); done(); - } + }, ); }); diff --git a/handwritten/google-cloud-dns/test/record.ts b/handwritten/google-cloud-dns/test/record.ts index e7174c43d546..ee2f3fb4d494 100644 --- a/handwritten/google-cloud-dns/test/record.ts +++ b/handwritten/google-cloud-dns/test/record.ts @@ -15,7 +15,7 @@ import * as promisify from '@google-cloud/promisify'; import * as assert from 'assert'; import {describe, it, before, beforeEach} from 'mocha'; -import * as proxyquire from 'proxyquire'; +import {proxyquire} from 'google-test-utils'; // eslint-disable-next-line @typescript-eslint/no-unused-vars import {Record} from '../src'; diff --git a/handwritten/google-cloud-dns/test/zone.ts b/handwritten/google-cloud-dns/test/zone.ts index 07681f51e591..cc5c517f7808 100644 --- a/handwritten/google-cloud-dns/test/zone.ts +++ b/handwritten/google-cloud-dns/test/zone.ts @@ -17,7 +17,7 @@ import * as promisify from '@google-cloud/promisify'; import arrify = require('arrify'); import * as assert from 'assert'; import {describe, it, before, beforeEach} from 'mocha'; -import * as proxyquire from 'proxyquire'; +import {proxyquire} from 'google-test-utils'; import {CoreOptions, OptionsWithUri, Response} from 'request'; import * as crypto from 'crypto'; @@ -187,7 +187,7 @@ describe('Zone', () => { zone.createChange = ( options: CreateChangeRequest, - callback: Function + callback: Function, ) => { assert.strictEqual(options.add, records); callback(); @@ -215,7 +215,7 @@ describe('Zone', () => { type: crypto.randomUUID(), rrdatas: [crypto.randomUUID(), crypto.randomUUID()], }, - recordJson + recordJson, ); return { @@ -312,7 +312,7 @@ describe('Zone', () => { assert.strictEqual(err, error); assert.strictEqual(apiResponse_, apiResponse); done(); - } + }, ); }); }); @@ -342,7 +342,7 @@ describe('Zone', () => { assert.strictEqual(change_.metadata, apiResponse); assert.strictEqual(apiResponse_, apiResponse); done(); - } + }, ); }); }); @@ -390,7 +390,7 @@ describe('Zone', () => { zone.createChange = ( options: CreateChangeRequest, - callback: Function + callback: Function, ) => { assert.deepStrictEqual(options.delete, [recordsToDelete]); callback(); @@ -462,7 +462,7 @@ describe('Zone', () => { it('should delete non-NS and non-SOA records', done => { zone.deleteRecords = ( recordsToDelete: string[], - callback: Function + callback: Function, ) => { assert.deepStrictEqual(recordsToDelete, expectedRecordsToDelete); callback(); @@ -539,7 +539,7 @@ describe('Zone', () => { writeFileOverride = ( path_: string, content: string, - encoding: string + encoding: string, ) => { assert.strictEqual(path_, path); assert.strictEqual(content, expectedZonefileContents); @@ -559,7 +559,7 @@ describe('Zone', () => { path: string, content: string, encoding: string, - callback: Function + callback: Function, ) => { callback(error); }; @@ -579,7 +579,7 @@ describe('Zone', () => { path: string, content: string, encoding: string, - callback: Function + callback: Function, ) => { callback(); }; @@ -648,12 +648,12 @@ describe('Zone', () => { err: Error, changes: Change[], nextQuery: {}, - apiResponse_: Response + apiResponse_: Response, ) => { assert.strictEqual(err, error); assert.strictEqual(apiResponse_, apiResponse); done(); - } + }, ); }); }); @@ -703,14 +703,14 @@ describe('Zone', () => { err: Error, changes: Change[], nextQuery: {}, - apiResponse_: Response + apiResponse_: Response, ) => { assert.ifError(err); assert.strictEqual(changes[0], change); assert.strictEqual(changes[0].metadata, apiResponse.changes[0]); assert.strictEqual(apiResponse_, apiResponse); done(); - } + }, ); }); }); @@ -734,12 +734,12 @@ describe('Zone', () => { err: Error, changes: Change[], nextQuery: {}, - apiResponse_: Response + apiResponse_: Response, ) => { assert.strictEqual(err, error); assert.strictEqual(apiResponse_, apiResponse); done(); - } + }, ); }); @@ -795,13 +795,13 @@ describe('Zone', () => { err: Error, records: Record[], nextQuery: {}, - apiResponse_: Response + apiResponse_: Response, ) => { assert.ifError(err); assert.strictEqual(records[0], record); assert.strictEqual(apiResponse_, apiResponse); done(); - } + }, ); it('should not require a query', done => { @@ -866,7 +866,7 @@ describe('Zone', () => { readFileOverride = ( path: string, encoding: string, - callback: Function + callback: Function, ) => { callback(error); }; @@ -897,7 +897,7 @@ describe('Zone', () => { readFileOverride = ( path: string, encoding: string, - callback: Function + callback: Function, ) => { callback(); }; @@ -906,7 +906,7 @@ describe('Zone', () => { it('should add records', done => { zone.addRecords = ( recordsToCreate: FakeRecord[], - callback: Function + callback: Function, ) => { assert.strictEqual(recordsToCreate.length, 1); const recordToCreate = recordsToCreate[0]; @@ -998,7 +998,7 @@ describe('Zone', () => { it('should create a change', done => { zone.createChange = ( options: CreateChangeRequest, - callback: Function + callback: Function, ) => { assert.strictEqual(options.add, recordsToCreate); assert.strictEqual(options.delete, recordsToDelete); diff --git a/handwritten/logging-bunyan/package.json b/handwritten/logging-bunyan/package.json index 74090d827716..e623a2659d61 100644 --- a/handwritten/logging-bunyan/package.json +++ b/handwritten/logging-bunyan/package.json @@ -42,7 +42,7 @@ "presystem-test": "pnpm run compile", "samples-test": "cd samples/ && npm link ../ && npm test && cd ../", "system-test": "node ../../bin/run-test.cjs build/system-test --timeout 600000", - "test": "cross-env NODE_OPTIONS='--no-deprecation' node ../../bin/run-test.cjs --proxyquire-shim build/test", + "test": "cross-env NODE_OPTIONS='--no-deprecation' node ../../bin/run-test.cjs build/test", "clean": "gts clean", "compile": "tsc -p .", "postcompile": "cpy \"src/types/*\" build/src/types", @@ -70,6 +70,7 @@ "cross-env": "^7.0.3", "delay": "^5.0.0", "express": "^4.16.3", + "google-test-utils": "^0.4.0", "gts": "^6.0.2", "jsdoc": "^4.0.0", "jsdoc-fresh": "^6.1.0", diff --git a/handwritten/logging-bunyan/test/index.ts b/handwritten/logging-bunyan/test/index.ts index 9e91fe2665fe..2f39cc7a58f9 100644 --- a/handwritten/logging-bunyan/test/index.ts +++ b/handwritten/logging-bunyan/test/index.ts @@ -13,7 +13,7 @@ // limitations under the License. import * as assert from 'assert'; import {describe, it, beforeEach, afterEach} from 'mocha'; -import * as proxyquire from 'proxyquire'; +import {proxyquire} from 'google-test-utils'; import {inspect} from 'util'; import {LoggingBunyan} from '../src'; diff --git a/handwritten/logging-bunyan/test/middleware/test-express.ts b/handwritten/logging-bunyan/test/middleware/test-express.ts index 99920c4ca522..b96fd0f4857d 100644 --- a/handwritten/logging-bunyan/test/middleware/test-express.ts +++ b/handwritten/logging-bunyan/test/middleware/test-express.ts @@ -17,7 +17,7 @@ import * as assert from 'assert'; import {describe, it, beforeEach} from 'mocha'; import {GCPEnv} from 'google-auth-library'; -import * as proxyquire from 'proxyquire'; +import {proxyquire} from 'google-test-utils'; // types-only import. Actual require is done through proxyquire below. import {MiddlewareOptions} from '../../src/middleware/express'; diff --git a/handwritten/logging-winston/package.json b/handwritten/logging-winston/package.json index 95428131365c..c7c7cf6a01f0 100644 --- a/handwritten/logging-winston/package.json +++ b/handwritten/logging-winston/package.json @@ -42,7 +42,7 @@ "samples-test": "cd samples/ && npm link ../ && npm test && cd ../", "presystem-test": "pnpm run pretest", "system-test": "node ../../bin/run-test.cjs build/system-test --timeout 600000", - "test": "cross-env NODE_OPTIONS='--no-deprecation' node ../../bin/run-test.cjs --proxyquire-shim build/test", + "test": "cross-env NODE_OPTIONS='--no-deprecation' node ../../bin/run-test.cjs build/test", "clean": "gts clean", "compile": "tsc -p .", "fix": "gts fix", @@ -67,6 +67,7 @@ "c8": "^10.1.3", "codecov": "^3.8.3", "cross-env": "^7.0.3", + "google-test-utils": "^0.4.0", "gts": "^6.0.2", "jsdoc": "^4.0.5", "jsdoc-fresh": "^6.1.0", diff --git a/handwritten/logging-winston/test/common.ts b/handwritten/logging-winston/test/common.ts index 39401702c6ee..e5acd8bc7781 100644 --- a/handwritten/logging-winston/test/common.ts +++ b/handwritten/logging-winston/test/common.ts @@ -15,7 +15,7 @@ import * as assert from 'assert'; import {describe, it, beforeEach} from 'mocha'; import * as nodeutil from 'util'; -import * as proxyquire from 'proxyquire'; +import {proxyquire} from 'google-test-utils'; import {Options} from '../src'; import {Entry, Logging, LogSync, Log} from '@google-cloud/logging'; import * as instrumentation from '@google-cloud/logging/build/src/utils/instrumentation'; diff --git a/handwritten/logging-winston/test/index.ts b/handwritten/logging-winston/test/index.ts index 13412aa4e742..bca6f2980aae 100644 --- a/handwritten/logging-winston/test/index.ts +++ b/handwritten/logging-winston/test/index.ts @@ -15,7 +15,7 @@ import * as assert from 'assert'; import {describe, it, beforeEach} from 'mocha'; import * as TransportStream from 'winston-transport'; -import * as proxyquire from 'proxyquire'; +import {proxyquire} from 'google-test-utils'; import {Options} from '../src'; describe('logging-winston', () => { diff --git a/handwritten/logging-winston/test/middleware/express.ts b/handwritten/logging-winston/test/middleware/express.ts index 40a1853601dc..ea5d747217f1 100644 --- a/handwritten/logging-winston/test/middleware/express.ts +++ b/handwritten/logging-winston/test/middleware/express.ts @@ -18,7 +18,7 @@ import {GCPEnv} from 'google-auth-library'; import {LogEntry} from 'winston'; import * as TransportStream from 'winston-transport'; import * as winston from 'winston'; -import * as proxyquire from 'proxyquire'; +import {proxyquire} from 'google-test-utils'; import {Options} from '../../src'; // types-only import. Actual require is done through proxyquire below. diff --git a/handwritten/logging-winston/test/stackdriver-trace-integration.ts b/handwritten/logging-winston/test/stackdriver-trace-integration.ts index ed0e668c4bbb..52142aad48df 100644 --- a/handwritten/logging-winston/test/stackdriver-trace-integration.ts +++ b/handwritten/logging-winston/test/stackdriver-trace-integration.ts @@ -14,7 +14,7 @@ import * as assert from 'assert'; import {describe, it, before, beforeEach, after} from 'mocha'; -import * as proxyquire from 'proxyquire'; +import {proxyquire} from 'google-test-utils'; import * as winston from 'winston'; import * as loggingWinstonLibTypes from '../src/index'; diff --git a/handwritten/logging/package.json b/handwritten/logging/package.json index 10a866d5d91d..fb3a5fd594ce 100644 --- a/handwritten/logging/package.json +++ b/handwritten/logging/package.json @@ -40,7 +40,7 @@ "presystem-test": "pnpm run compile", "system-test": "node ../../bin/run-test.cjs build/system-test --timeout 600000", "pretest": "pnpm run compile", - "test": "cross-env NODE_OPTIONS='--no-deprecation' node ../../bin/run-test.cjs --proxyquire-shim build/test", + "test": "cross-env NODE_OPTIONS='--no-deprecation' node ../../bin/run-test.cjs build/test", "precompile": "gts clean", "postpublish": "./.kokoro/publish-min.sh" }, @@ -86,6 +86,7 @@ "codecov": "^3.6.5", "cross-env": "^7.0.3", "gapic-tools": "^2.2.0", + "google-test-utils": "^0.4.0", "gts": "^5.0.0", "http2spy": "^2.0.0", "jsdoc": "^4.0.0", diff --git a/handwritten/logging/test/entry.ts b/handwritten/logging/test/entry.ts index a66227b63655..083a824ded4a 100644 --- a/handwritten/logging/test/entry.ts +++ b/handwritten/logging/test/entry.ts @@ -15,7 +15,7 @@ import * as assert from 'assert'; import {describe, it, before, beforeEach, afterEach} from 'mocha'; import * as extend from 'extend'; -import * as proxyquire from 'proxyquire'; +import {proxyquire} from 'google-test-utils'; import * as entryTypes from '../src/entry'; import * as common from '../src/utils/common'; import * as http from 'http'; @@ -222,7 +222,7 @@ describe('Entry', () => { it('should pass removeCircular to objToStruct_', done => { fakeObjToStruct = ( obj: {}, - options: common.ObjectToStructConverterConfig, + options: common.ObjectToStructConverterConfig ) => { assert.strictEqual(options.removeCircular, true); done(); @@ -325,7 +325,7 @@ describe('Entry', () => { }); after(() => { - sdk.shutdown(); + return sdk.shutdown(); }); it('should detect open telemetry trace and span if open telemetry context present', () => { @@ -335,12 +335,12 @@ describe('Entry', () => { const json = entry.toJSON(); assert.strictEqual( json.trace, - `projects//traces/${span.spanContext().traceId}`, + `projects//traces/${span.spanContext().traceId}` ); assert.strictEqual(json.spanId, span.spanContext().spanId); assert.strictEqual( json.traceSampled, - (span.spanContext().traceFlags & 1) !== 0, + (span.spanContext().traceFlags & 1) !== 0 ); }); }); @@ -360,12 +360,12 @@ describe('Entry', () => { const json = entry.toJSON(); assert.strictEqual( json.trace, - `projects//traces/${span.spanContext().traceId}`, + `projects//traces/${span.spanContext().traceId}` ); assert.strictEqual(json.spanId, span.spanContext().spanId); assert.strictEqual( json.traceSampled, - (span.spanContext().traceFlags & 1) !== 0, + (span.spanContext().traceFlags & 1) !== 0 ); }); }); @@ -413,7 +413,7 @@ describe('Entry', () => { entry.data = 'this is a log'; const json = entry.toStructuredJSON(); assert( - withinExpectedTimeBoundaries(nanosAndSecondsToDate(json.timestamp!)), + withinExpectedTimeBoundaries(nanosAndSecondsToDate(json.timestamp!)) ); delete json.timestamp; const expectedJSON = { @@ -441,7 +441,7 @@ describe('Entry', () => { entry.metadata.timestamp = new Date(); const json = entry.toStructuredJSON(); assert( - withinExpectedTimeBoundaries(nanosAndSecondsToDate(json.timestamp!)), + withinExpectedTimeBoundaries(nanosAndSecondsToDate(json.timestamp!)) ); }); @@ -503,7 +503,7 @@ describe('Entry', () => { }); after(() => { - sdk.shutdown(); + return sdk.shutdown(); }); it('should detect open telemetry trace and span if open telemetry context present', () => { @@ -513,15 +513,15 @@ describe('Entry', () => { const json = entry.toStructuredJSON(); assert.strictEqual( json[entryTypes.TRACE_KEY], - `projects//traces/${span.spanContext().traceId}`, + `projects//traces/${span.spanContext().traceId}` ); assert.strictEqual( json[entryTypes.SPAN_ID_KEY], - span.spanContext().spanId, + span.spanContext().spanId ); assert.strictEqual( json[entryTypes.TRACE_SAMPLED_KEY], - (span.spanContext().traceFlags & 1) !== 0, + (span.spanContext().traceFlags & 1) !== 0 ); }); }); @@ -541,15 +541,15 @@ describe('Entry', () => { const json = entry.toStructuredJSON(); assert.strictEqual( json[entryTypes.TRACE_KEY], - `projects//traces/${span.spanContext().traceId}`, + `projects//traces/${span.spanContext().traceId}` ); assert.strictEqual( json[entryTypes.SPAN_ID_KEY], - span.spanContext().spanId, + span.spanContext().spanId ); assert.strictEqual( json[entryTypes.TRACE_SAMPLED_KEY], - (span.spanContext().traceFlags & 1) !== 0, + (span.spanContext().traceFlags & 1) !== 0 ); }); }); @@ -571,7 +571,7 @@ describe('Entry', () => { assert.strictEqual(json[entryTypes.SPAN_ID_KEY], expected.spanId); assert.strictEqual( json[entryTypes.TRACE_SAMPLED_KEY], - expected.traceSampled, + expected.traceSampled ); }); }); diff --git a/handwritten/logging/test/index.ts b/handwritten/logging/test/index.ts index 73ae9f61581a..b7d8eb98a54f 100644 --- a/handwritten/logging/test/index.ts +++ b/handwritten/logging/test/index.ts @@ -18,7 +18,7 @@ import arrify = require('arrify'); import * as assert from 'assert'; import {describe, it, beforeEach, before} from 'mocha'; import * as extend from 'extend'; -import * as proxyquire from 'proxyquire'; +import {proxyquire} from 'google-test-utils'; import { Logging as LOGGING, LoggingOptions, @@ -215,8 +215,8 @@ describe('Logging', () => { libVersion: version, scopes: EXPECTED_SCOPES, }, - options, - ), + options + ) ); return fakeGoogleAuthInstance; }; @@ -245,8 +245,8 @@ describe('Logging', () => { libVersion: version, scopes: EXPECTED_SCOPES, }, - options, - ), + options + ) ); }); @@ -270,17 +270,13 @@ describe('Logging', () => { it('should throw if a name is not provided', () => { const error = new Error('A sink name must be provided.'); // eslint-disable-next-line @typescript-eslint/no-explicit-any - (logging as any).createSink().then(noop, (err: Error) => { - assert.deepStrictEqual(err, error); - }); + return assert.rejects((logging as any).createSink(), error); }); it('should throw if a config object is not provided', () => { const error = new Error('A sink configuration object must be provided.'); // eslint-disable-next-line @typescript-eslint/no-explicit-any - (logging as any).createSink(SINK_NAME).then(noop, (err: Error) => { - assert.deepStrictEqual(err, error); - }); + return assert.rejects((logging as any).createSink(SINK_NAME), error); }); it('should set acls for a Dataset destination', async () => { @@ -354,7 +350,7 @@ describe('Logging', () => { logging.configService.createSink = async ( // eslint-disable-next-line @typescript-eslint/no-explicit-any reqOpts: any, - gaxOpts: {}, + gaxOpts: {} ) => { const expectedParent = 'projects/' + logging.projectId; assert.strictEqual(reqOpts.parent, expectedParent); @@ -376,11 +372,11 @@ describe('Logging', () => { // eslint-disable-next-line @typescript-eslint/no-explicit-any reqOpts: any, // eslint-disable-next-line @typescript-eslint/no-unused-vars - gaxOpts: {}, + gaxOpts: {} ) => { assert.strictEqual( reqOpts.uniqueWriterIdentity, - config.uniqueWriterIdentity, + config.uniqueWriterIdentity ); assert.strictEqual(reqOpts.sink.uniqueWriterIdentity, undefined); return [{}]; @@ -399,7 +395,7 @@ describe('Logging', () => { logging.configService.createSink = async ( // eslint-disable-next-line @typescript-eslint/no-explicit-any reqOpts: any, - gaxOpts: {}, + gaxOpts: {} ) => { assert.strictEqual(reqOpts.sink.gaxOptions, undefined); assert.strictEqual(gaxOpts, config.gaxOptions); @@ -424,9 +420,10 @@ describe('Logging', () => { throw error; }; - logging - .createSink(SINK_NAME, {} as CreateSinkRequest) - .then(noop, (err: Error) => assert.deepStrictEqual(err, error)); + return assert.rejects( + logging.createSink(SINK_NAME, {} as CreateSinkRequest), + error + ); }); }); @@ -455,7 +452,7 @@ describe('Logging', () => { const [sink_, apiResponse_] = await logging.createSink( SINK_NAME, - {} as CreateSinkRequest, + {} as CreateSinkRequest ); assert.strictEqual(sink_, sink); assert.strictEqual(sink_.metadata, apiResponse); @@ -487,7 +484,7 @@ describe('Logging', () => { logging.loggingService.listLogEntries = async ( // eslint-disable-next-line @typescript-eslint/no-explicit-any reqOpts: any, - gaxOpts: {}, + gaxOpts: {} ) => { assert.deepStrictEqual(reqOpts, { filter: reqOpts?.filter, @@ -512,7 +509,7 @@ describe('Logging', () => { logging.loggingService.listLogEntries = async ( // eslint-disable-next-line @typescript-eslint/no-explicit-any - reqOpts: any, + reqOpts: any ) => { assert.deepStrictEqual(reqOpts.resourceNames, resourceNames); return [[]]; @@ -526,7 +523,7 @@ describe('Logging', () => { logging.loggingService.listLogEntries = async ( reqOpts: {}, - gaxOpts: {}, + gaxOpts: {} ) => { assert.deepStrictEqual( reqOpts, @@ -534,7 +531,7 @@ describe('Logging', () => { filter: 'timestamp > "2020-11-11T15:01:23.045123456Z"', orderBy: 'timestamp desc', resourceNames: ['projects/' + logging.projectId], - }), + }) ); assert.deepStrictEqual(gaxOpts, { @@ -552,7 +549,7 @@ describe('Logging', () => { logging.loggingService.listLogEntries = async ( // eslint-disable-next-line @typescript-eslint/no-explicit-any reqOpts: any, - gaxOpts: {}, + gaxOpts: {} ) => { assert.deepStrictEqual( reqOpts, @@ -560,7 +557,7 @@ describe('Logging', () => { filter: reqOpts?.filter, orderBy: 'timestamp desc', resourceNames: ['projects/' + logging.projectId], - }), + }) ); assert.deepStrictEqual(gaxOpts, { autoPaginate: undefined, @@ -614,7 +611,7 @@ describe('Logging', () => { logging.loggingService.listLogEntries = async ( // eslint-disable-next-line @typescript-eslint/no-explicit-any reqOpts: any, - gaxOpts: {}, + gaxOpts: {} ) => { assert.deepStrictEqual(reqOpts, { a: 'b', @@ -643,7 +640,7 @@ describe('Logging', () => { }); it('should reject promise with error', () => { - logging.getEntries().then(noop, err => assert.strictEqual(err, error)); + return assert.rejects(logging.getEntries(), error); }); }); @@ -692,7 +689,7 @@ describe('Logging', () => { it('should make request once reading', done => { logging.loggingService.listLogEntriesStream = ( reqOpts: {}, - gaxOpts: {}, + gaxOpts: {} ) => { assert.deepStrictEqual(reqOpts, { resourceNames: ['projects/' + logging.projectId], @@ -721,7 +718,7 @@ describe('Logging', () => { logging = new LOGGING({projectId: PROJECT_ID}); logging.loggingService.listLogEntriesStream = ( reqOpts: {}, - gaxOpts: {}, + gaxOpts: {} ) => { assert.deepStrictEqual(reqOpts, { resourceNames: ['projects/' + logging.projectId], @@ -758,12 +755,12 @@ describe('Logging', () => { { filter: 'custom filter', }, - OPTIONS, + OPTIONS ); logging = new LOGGING({projectId: PROJECT_ID}); logging.loggingService.listLogEntriesStream = ( reqOpts: {}, - gaxOpts: {}, + gaxOpts: {} ) => { assert.deepStrictEqual(reqOpts, { resourceNames: ['projects/' + logging.projectId], @@ -908,9 +905,7 @@ describe('Logging', () => { logging.loggingService.listLogs = async () => { throw error; }; - logging - .getLogs(OPTIONS) - .then(noop, err => assert.strictEqual(err, error)); + return assert.rejects(logging.getLogs(OPTIONS), error); }); }); @@ -1079,9 +1074,7 @@ describe('Logging', () => { logging.configService.listSinks = async () => { throw error; }; - logging - .getSinks(OPTIONS) - .then(noop, err => assert.strictEqual(err, error)); + return assert.rejects(logging.getSinks(OPTIONS), error); }); }); @@ -1561,9 +1554,7 @@ describe('Logging', () => { }); it('should return error', () => { - logging - .setAclForBucket_(CONFIG) - .then(noop, err => assert.deepStrictEqual(err, error)); + return assert.rejects(logging.setAclForBucket_(CONFIG), error); }); }); @@ -1610,9 +1601,7 @@ describe('Logging', () => { }); it('should reject with error', () => { - logging - .setAclForDataset_(CONFIG) - .then(noop, err => assert.deepStrictEqual(err, error)); + return assert.rejects(logging.setAclForDataset_(CONFIG), error); }); }); @@ -1658,9 +1647,7 @@ describe('Logging', () => { }); it('should reject with error', () => { - logging - .setAclForDataset_(CONFIG) - .then(noop, err => assert.deepStrictEqual(err, error)); + return assert.rejects(logging.setAclForDataset_(CONFIG), error); }); }); @@ -1717,9 +1704,7 @@ describe('Logging', () => { }); it('should throw error', () => { - logging - .setAclForTopic_(CONFIG) - .then(noop, err => assert.deepStrictEqual(err, error)); + return assert.rejects(logging.setAclForTopic_(CONFIG), error); }); }); @@ -1764,9 +1749,7 @@ describe('Logging', () => { }); it('should throw error', () => { - logging - .setAclForTopic_(CONFIG) - .then(noop, err => assert.deepStrictEqual(err, error)); + return assert.rejects(logging.setAclForTopic_(CONFIG), error); }); }); diff --git a/handwritten/logging/test/log.ts b/handwritten/logging/test/log.ts index e535e739b694..7dbc42c5a43d 100644 --- a/handwritten/logging/test/log.ts +++ b/handwritten/logging/test/log.ts @@ -15,7 +15,7 @@ import * as assert from 'assert'; import {describe, it, before, beforeEach, afterEach} from 'mocha'; import * as extend from 'extend'; -import * as proxyquire from 'proxyquire'; +import {proxyquire} from 'google-test-utils'; import * as sinon from 'sinon'; import {Entry, Logging} from '../src'; import {Log as LOG, LogOptions, WriteOptions} from '../src/log'; @@ -123,8 +123,8 @@ describe('Log', () => { assert( callbackifyFake.callbackifyAll.calledWithExactly( Log, - sinon.match({exclude: ['entry', 'getEntriesStream']}), - ), + sinon.match({exclude: ['entry', 'getEntriesStream']}) + ) ); }); @@ -140,7 +140,7 @@ describe('Log', () => { const log = new Log(LOGGING, LOG_NAME); assert.strictEqual( log.formattedName_, - logCommon.formatLogName('{{project-id}}', LOG_NAME), + logCommon.formatLogName('{{project-id}}', LOG_NAME) ); }); @@ -172,8 +172,8 @@ describe('Log', () => { logName: log.formattedName_, }, undefined, - undefined, - ), + undefined + ) ); }); @@ -186,8 +186,8 @@ describe('Log', () => { logName: log.formattedName_, }, undefined, - log.defaultWriteDeleteCallback, - ), + log.defaultWriteDeleteCallback + ) ); log.defaultWriteDeleteCallback = undefined; }); @@ -195,7 +195,7 @@ describe('Log', () => { it('should accept gaxOptions', async () => { await log.delete({}); assert( - log.logging.loggingService.deleteLog.calledWith(sinon.match.any, {}), + log.logging.loggingService.deleteLog.calledWith(sinon.match.any, {}) ); }); }); @@ -235,7 +235,7 @@ describe('Log', () => { assert( log.logging.getEntries.calledWithExactly({ filter: `logName="${LOG_NAME_FORMATTED}"`, - }), + }) ); }); @@ -273,7 +273,7 @@ describe('Log', () => { assert( log.logging.getEntriesStream.calledWithExactly({ log: LOG_NAME_ENCODED, - }), + }) ); }); @@ -292,9 +292,9 @@ describe('Log', () => { { log: LOG_NAME_ENCODED, }, - options, - ), - ), + options + ) + ) ); }); }); @@ -312,7 +312,7 @@ describe('Log', () => { assert( log.logging.tailEntries.calledWithExactly({ log: LOG_NAME_ENCODED, - }), + }) ); }); @@ -331,9 +331,9 @@ describe('Log', () => { { log: LOG_NAME_ENCODED, }, - options, - ), - ), + options + ) + ) ); }); }); @@ -388,8 +388,8 @@ describe('Log', () => { }, }, undefined, - undefined, - ), + undefined + ) ); }); @@ -424,8 +424,8 @@ describe('Log', () => { log.logging.loggingService.writeLogEntries.calledOnceWith( sinon.match({ resource: reusableDetectedResource, - }), - ), + }) + ) ); }); @@ -454,8 +454,8 @@ describe('Log', () => { resource: EXPECTED_RESOURCE, }, undefined, - undefined, - ), + undefined + ) ); }); @@ -470,8 +470,8 @@ describe('Log', () => { resource: FAKE_RESOURCE, }, undefined, - undefined, - ), + undefined + ) ); }); @@ -487,8 +487,8 @@ describe('Log', () => { resource: FAKE_RESOURCE, }, undefined, - log.defaultWriteDeleteCallback, - ), + log.defaultWriteDeleteCallback + ) ); log.defaultWriteDeleteCallback = undefined; }); @@ -503,8 +503,8 @@ describe('Log', () => { log.logging.loggingService.writeLogEntries.calledOnceWith( sinon.match({ entries: 'decorated entries', - }), - ), + }) + ) ); }); @@ -517,8 +517,8 @@ describe('Log', () => { log.logging.loggingService.writeLogEntries.calledOnceWith( sinon.match({ entries: arrifiedEntries, - }), - ), + }) + ) ); }); @@ -530,8 +530,8 @@ describe('Log', () => { log.logging.loggingService.writeLogEntries.calledOnceWith( sinon.match({ entries: ENTRIES, - }), - ), + }) + ) ); }); @@ -541,8 +541,8 @@ describe('Log', () => { log.logging.loggingService.writeLogEntries.calledOnceWith( sinon.match({ partialSuccess: true, - }), - ), + }) + ) ); }); @@ -553,8 +553,8 @@ describe('Log', () => { sinon.match({ dryRun: true, partialSuccess: false, - }), - ), + }) + ) ); }); @@ -567,8 +567,8 @@ describe('Log', () => { log.logging.loggingService.writeLogEntries.calledOnceWith( sinon.match({ partialSuccess: true, - }), - ), + }) + ) ); instrumentation.setInstrumentationStatus(true); }); @@ -582,8 +582,8 @@ describe('Log', () => { log.logging.loggingService.writeLogEntries.calledOnceWith( sinon.match({ partialSuccess: true, - }), - ), + }) + ) ); }); @@ -597,8 +597,8 @@ describe('Log', () => { { maxRetries: 1, }, - sinon.match.any, - ), + sinon.match.any + ) ); log.logging.loggingService.writeLogEntries.reset(); await log.write(ENTRIES, {gaxOptions: {maxRetries: 10}}); @@ -608,8 +608,8 @@ describe('Log', () => { { maxRetries: 10, }, - sinon.match.any, - ), + sinon.match.any + ) ); }); }); @@ -656,7 +656,7 @@ describe('Log', () => { .returns({} as EntryJson); log.decorateEntries([entry]); assert( - localJSONStub.calledWithExactly({removeCircular: true}, PROJECT_ID), + localJSONStub.calledWithExactly({removeCircular: true}, PROJECT_ID) ); }); @@ -749,11 +749,11 @@ describe('Log', () => { assert.ok(log.jsonFieldsToTruncate.length > 1); assert.ok(log.jsonFieldsToTruncate[0] === TRUNCATE_FIELD); const notExists = log.jsonFieldsToTruncate.filter( - (str: string) => str === INVALID_TRUNCATE_FIELD, + (str: string) => str === INVALID_TRUNCATE_FIELD ); assert.strictEqual(notExists.length, 0); const existOnce = log.jsonFieldsToTruncate.filter( - (str: string) => str === TRUNCATE_FIELD, + (str: string) => str === TRUNCATE_FIELD ); assert.strictEqual(existOnce.length, 1); }); diff --git a/handwritten/logging/test/middleware/express/test-make-middleware.ts b/handwritten/logging/test/middleware/express/test-make-middleware.ts index 47740b2ad306..3b65cc915811 100644 --- a/handwritten/logging/test/middleware/express/test-make-middleware.ts +++ b/handwritten/logging/test/middleware/express/test-make-middleware.ts @@ -17,7 +17,7 @@ import * as assert from 'assert'; import {describe, it, beforeEach} from 'mocha'; import * as EventEmitter from 'events'; -import * as proxyquire from 'proxyquire'; +import {proxyquire} from 'google-test-utils'; const FAKE_PROJECT_ID = 'project-🦄'; @@ -45,7 +45,7 @@ describe('middleware/express/make-middleware', () => { '../../../src/middleware/express/make-middleware', { '../../../src/utils/context': FAKE_CONTEXT, - }, + } ); it('should return a function accepting 3 arguments', () => { @@ -133,7 +133,7 @@ describe('middleware/express/make-middleware', () => { const middleware = makeMiddleware( FAKE_PROJECT_ID, () => {}, - emitRequestLog, + emitRequestLog ); middleware(fakeRequest, fakeResponse, () => {}); diff --git a/handwritten/logging/test/sink.ts b/handwritten/logging/test/sink.ts index 598e63c70bf7..ddffc2b28366 100644 --- a/handwritten/logging/test/sink.ts +++ b/handwritten/logging/test/sink.ts @@ -16,7 +16,7 @@ import * as callbackify from '@google-cloud/promisify'; import * as assert from 'assert'; import {describe, it, before, beforeEach, afterEach} from 'mocha'; import * as extend from 'extend'; -import * as proxyquire from 'proxyquire'; +import {proxyquire} from 'google-test-utils'; import * as sinon from 'sinon'; import {Sink as SINK} from '../src/sink'; import {Logging, CreateSinkRequest, LogSink} from '../src/index'; @@ -75,7 +75,7 @@ describe('Sink', () => { it('should localize the formatted name', () => { assert.strictEqual( sink.formattedName_, - 'projects/' + LOGGING.projectId + '/sinks/' + SINK_NAME, + 'projects/' + LOGGING.projectId + '/sinks/' + SINK_NAME ); }); }); @@ -98,7 +98,7 @@ describe('Sink', () => { sink.logging.auth.getProjectId = async () => PROJECT_ID; sink.logging.configService.deleteSink = async ( reqOpts: {}, - gaxOpts: {}, + gaxOpts: {} ) => { assert.deepStrictEqual(reqOpts, { sinkName: sink.formattedName_, @@ -113,7 +113,7 @@ describe('Sink', () => { const gaxOptions = {}; sink.logging.configService.deleteSink = async ( reqOpts: {}, - gaxOpts: {}, + gaxOpts: {} ) => { assert.deepStrictEqual(gaxOpts, gaxOptions); }; @@ -201,10 +201,7 @@ describe('Sink', () => { sink.getMetadata = async () => { throw error; }; - sink.setMetadata(METADATA).then( - () => {}, - err => assert.strictEqual(err, error), - ); + return assert.rejects(sink.setMetadata(METADATA), error); }); it('should execute gax method', async () => { @@ -213,7 +210,7 @@ describe('Sink', () => { sink.getMetadata = async () => [currentMetadata] as any; sink.logging.configService.updateSink = async ( reqOpts: {}, - gaxOpts: {}, + gaxOpts: {} ) => { assert.deepStrictEqual(reqOpts, { sinkName: sink.formattedName_, diff --git a/handwritten/logging/test/utils/metadata.ts b/handwritten/logging/test/utils/metadata.ts index 9425f8ff5436..f2184c06fa27 100644 --- a/handwritten/logging/test/utils/metadata.ts +++ b/handwritten/logging/test/utils/metadata.ts @@ -17,7 +17,7 @@ import {describe, it, beforeEach, before, after, afterEach} from 'mocha'; import BigNumber from 'bignumber.js'; import * as extend from 'extend'; import {GCPEnv} from 'google-auth-library'; -import * as proxyquire from 'proxyquire'; +import {proxyquire} from 'google-test-utils'; let instanceOverride: {} | null; const fakeGcpMetadata = { @@ -298,7 +298,7 @@ describe('metadata', () => { }; await assert.rejects( metadata.getGKEDescriptor(), - (err: Error) => err === FAKE_ERROR, + (err: Error) => err === FAKE_ERROR ); }); @@ -306,7 +306,7 @@ describe('metadata', () => { readFileShouldError = true; await assert.doesNotReject(metadata.getGKEDescriptor(), (err: Error) => - err.message.includes(FAKE_READFILE_ERROR_MESSAGE), + err.message.includes(FAKE_READFILE_ERROR_MESSAGE) ); }); }); diff --git a/handwritten/pubsub/package.json b/handwritten/pubsub/package.json index 138a758e33df..55ecf7b6ed95 100644 --- a/handwritten/pubsub/package.json +++ b/handwritten/pubsub/package.json @@ -35,7 +35,7 @@ "system-test": "node ../../bin/run-test.cjs build/system-test --timeout 600000", "samples-test": "pnpm run link-samples && pnpm test && cd ../", "link-samples": "cd samples/ && pnpm link ../ && pnpm install", - "test": "node ../../bin/run-test.cjs --proxyquire-shim build/test", + "test": "node ../../bin/run-test.cjs build/test", "lint": "gts check", "predocs": "pnpm run compile", "docs": "jsdoc -c .jsdoc.js", @@ -88,7 +88,7 @@ "codecov": "^3.8.3", "execa": "~5.1.0", "gapic-tools": "^2.2.0", - "google-test-utils": "^0.3.0", + "google-test-utils": "^0.4.0", "gts": "^6.0.0", "jsdoc": "^4.0.4", "jsdoc-fresh": "^6.1.0", diff --git a/handwritten/pubsub/test/iam.ts b/handwritten/pubsub/test/iam.ts index a1f73f8bf35d..bc20797c21ab 100644 --- a/handwritten/pubsub/test/iam.ts +++ b/handwritten/pubsub/test/iam.ts @@ -14,7 +14,7 @@ import * as assert from 'assert'; import {describe, it, before, beforeEach} from 'mocha'; -import * as proxyquire from 'proxyquire'; +import {proxyquire} from 'google-test-utils'; import * as iamTypes from '../src/iam'; import {PubSub, RequestConfig} from '../src/pubsub'; diff --git a/handwritten/pubsub/test/lease-manager.ts b/handwritten/pubsub/test/lease-manager.ts index d7fc2d8a2cfd..603e7015b30c 100644 --- a/handwritten/pubsub/test/lease-manager.ts +++ b/handwritten/pubsub/test/lease-manager.ts @@ -17,7 +17,7 @@ import * as assert from 'assert'; import {describe, it, before, beforeEach, afterEach} from 'mocha'; import {EventEmitter} from 'events'; -import * as proxyquire from 'proxyquire'; +import {proxyquire} from 'google-test-utils'; import * as sinon from 'sinon'; import * as defer from 'p-defer'; @@ -208,10 +208,7 @@ describe('LeaseManager', () => { subscriber.on('message', () => { assert.strictEqual(fakeLog!.called, true); - assert.strictEqual( - fakeLog!.fields!.severity, - 'INFO', - ); + assert.strictEqual(fakeLog!.fields!.severity, 'INFO'); assert.strictEqual(fakeLog!.args![1] as string, 'a'); assert.strictEqual(fakeLog!.args![2] as string, 'b'); done(); @@ -241,10 +238,7 @@ describe('LeaseManager', () => { await deferred.promise; assert.strictEqual(fakeLog.called, true); - assert.strictEqual( - fakeLog.fields!.severity, - 'ERROR', - ); + assert.strictEqual(fakeLog.fields!.severity, 'ERROR'); assert.strictEqual( (fakeLog.args![0] as string).includes('exception'), true, @@ -402,10 +396,7 @@ describe('LeaseManager', () => { // make sure the expired messages were forgotten assert.strictEqual(removeStub.callCount, badMessages.length); - assert.strictEqual( - fakeLog.fields!.severity, - 'WARNING', - ); + assert.strictEqual(fakeLog.fields!.severity, 'WARNING'); assert.strictEqual(fakeLog.called, true); badMessages.forEach((fakeMessage, i) => { diff --git a/handwritten/pubsub/test/message-stream.ts b/handwritten/pubsub/test/message-stream.ts index e9a0a5a1fad2..8c1916665e59 100644 --- a/handwritten/pubsub/test/message-stream.ts +++ b/handwritten/pubsub/test/message-stream.ts @@ -17,7 +17,7 @@ import * as assert from 'assert'; import {describe, it, before, beforeEach, afterEach} from 'mocha'; import {grpc} from 'google-gax'; -import * as proxyquire from 'proxyquire'; +import {proxyquire} from 'google-test-utils'; import * as sinon from 'sinon'; import {Duplex, PassThrough} from 'stream'; import * as defer from 'p-defer'; diff --git a/handwritten/pubsub/test/publisher/index.ts b/handwritten/pubsub/test/publisher/index.ts index c97be76729e7..123b77088448 100644 --- a/handwritten/pubsub/test/publisher/index.ts +++ b/handwritten/pubsub/test/publisher/index.ts @@ -18,7 +18,7 @@ import * as pfy from '@google-cloud/promisify'; import * as assert from 'assert'; import {describe, it, beforeEach, afterEach} from 'mocha'; import {EventEmitter} from 'events'; -import * as proxyquire from 'proxyquire'; +import {proxyquire} from 'google-test-utils'; import * as sinon from 'sinon'; import * as opentelemetry from '@opentelemetry/api'; import {Topic} from '../../src'; diff --git a/handwritten/pubsub/test/publisher/message-queues.ts b/handwritten/pubsub/test/publisher/message-queues.ts index d2d2ed7f0881..c18e96a39180 100644 --- a/handwritten/pubsub/test/publisher/message-queues.ts +++ b/handwritten/pubsub/test/publisher/message-queues.ts @@ -18,7 +18,7 @@ import {ServiceError} from 'google-gax'; import * as assert from 'assert'; import {describe, it, before, beforeEach, afterEach} from 'mocha'; import {EventEmitter} from 'events'; -import * as proxyquire from 'proxyquire'; +import {proxyquire} from 'google-test-utils'; import * as sinon from 'sinon'; import {RequestConfig, RequestCallback} from '../../src/pubsub'; diff --git a/handwritten/pubsub/test/pubsub.ts b/handwritten/pubsub/test/pubsub.ts index 61e6f6392f2c..1173d7c96f59 100644 --- a/handwritten/pubsub/test/pubsub.ts +++ b/handwritten/pubsub/test/pubsub.ts @@ -17,7 +17,7 @@ import arrify = require('arrify'); import * as assert from 'assert'; import {describe, it, before, beforeEach, after, afterEach} from 'mocha'; import * as gax from 'google-gax'; -import * as proxyquire from 'proxyquire'; +import {proxyquire} from 'google-test-utils'; import * as sinon from 'sinon'; import defer = require('p-defer'); diff --git a/handwritten/pubsub/test/snapshot.ts b/handwritten/pubsub/test/snapshot.ts index 5e5da3efec7a..63660a72e77f 100644 --- a/handwritten/pubsub/test/snapshot.ts +++ b/handwritten/pubsub/test/snapshot.ts @@ -15,7 +15,7 @@ import * as assert from 'assert'; import {ServiceError} from 'google-gax'; import {describe, it, beforeEach, before, after, afterEach} from 'mocha'; -import * as proxyquire from 'proxyquire'; +import {proxyquire} from 'google-test-utils'; import * as sinon from 'sinon'; import {PubSub, RequestConfig} from '../src/pubsub'; diff --git a/handwritten/pubsub/test/subscriber.ts b/handwritten/pubsub/test/subscriber.ts index a0c4b0336b96..280e44698981 100644 --- a/handwritten/pubsub/test/subscriber.ts +++ b/handwritten/pubsub/test/subscriber.ts @@ -19,7 +19,7 @@ import * as assert from 'assert'; import {describe, it, beforeEach, afterEach} from 'mocha'; import {EventEmitter} from 'events'; import {common as protobuf} from 'protobufjs'; -import * as proxyquire from 'proxyquire'; +import {proxyquire} from 'google-test-utils'; import * as sinon from 'sinon'; import {PassThrough} from 'stream'; import * as opentelemetry from '@opentelemetry/api'; diff --git a/handwritten/pubsub/test/subscription.ts b/handwritten/pubsub/test/subscription.ts index 4855ec9217a5..b86c5a60d732 100644 --- a/handwritten/pubsub/test/subscription.ts +++ b/handwritten/pubsub/test/subscription.ts @@ -16,7 +16,7 @@ import * as assert from 'assert'; import {describe, it, before, beforeEach, afterEach} from 'mocha'; import {EventEmitter} from 'events'; import {ServiceError} from 'google-gax'; -import * as proxyquire from 'proxyquire'; +import {proxyquire} from 'google-test-utils'; import * as sinon from 'sinon'; import {PubSub, RequestConfig} from '../src/pubsub'; diff --git a/handwritten/pubsub/test/topic.ts b/handwritten/pubsub/test/topic.ts index c918b21c64e9..c8e31cd3894c 100644 --- a/handwritten/pubsub/test/topic.ts +++ b/handwritten/pubsub/test/topic.ts @@ -15,7 +15,7 @@ import * as assert from 'assert'; import {describe, it, before, beforeEach, afterEach} from 'mocha'; import {CallOptions, ServiceError} from 'google-gax'; -import * as proxyquire from 'proxyquire'; +import {proxyquire} from 'google-test-utils'; import * as sinon from 'sinon'; import {google} from '../protos/protos'; diff --git a/handwritten/spanner/observability-test/batch-transaction.ts b/handwritten/spanner/observability-test/batch-transaction.ts index f3738c67ecef..3aa215842ec3 100644 --- a/handwritten/spanner/observability-test/batch-transaction.ts +++ b/handwritten/spanner/observability-test/batch-transaction.ts @@ -21,7 +21,7 @@ import * as pfy from '@google-cloud/promisify'; import * as assert from 'assert'; import {before, after, beforeEach, afterEach, describe, it} from 'mocha'; import * as extend from 'extend'; -import * as proxyquire from 'proxyquire'; +import {proxyquire} from 'google-test-utils'; import * as sinon from 'sinon'; const { AlwaysOnSampler, diff --git a/handwritten/spanner/observability-test/database.ts b/handwritten/spanner/observability-test/database.ts index 1c9410242d33..1b3a3e23df4b 100644 --- a/handwritten/spanner/observability-test/database.ts +++ b/handwritten/spanner/observability-test/database.ts @@ -30,7 +30,7 @@ import { } from '../src/transaction'; import {util} from '@google-cloud/common'; import {Transform} from 'stream'; -import * as proxyquire from 'proxyquire'; +import {proxyquire} from 'google-test-utils'; import * as sinon from 'sinon'; const {SpanStatusCode} = require('@opentelemetry/api'); const { diff --git a/handwritten/spanner/observability-test/helper.ts b/handwritten/spanner/observability-test/helper.ts index fc610a4f912f..45be0d2c891a 100644 --- a/handwritten/spanner/observability-test/helper.ts +++ b/handwritten/spanner/observability-test/helper.ts @@ -43,6 +43,7 @@ export const cacheSessionEvents = ['Cache hit: has usable multiplexed session']; * and referring to context causes type/value collision errors. */ export function setGlobalContextManager(manager: ContextManager) { + context.disable(); if (typeof manager.enable === 'function') { manager.enable(); } diff --git a/handwritten/spanner/observability-test/spanner.ts b/handwritten/spanner/observability-test/spanner.ts index a262314b2f79..8d9854f8fb52 100644 --- a/handwritten/spanner/observability-test/spanner.ts +++ b/handwritten/spanner/observability-test/spanner.ts @@ -188,6 +188,7 @@ describe('EndToEnd', async () => { const database = instance.database('database'); beforeEach(async () => { + setGlobalContextManager(contextManager); // To deflake expectations of session creation, let's // issue out a warm-up request request that'll ensure // that the MultiplexedSession is created deterministically. diff --git a/handwritten/spanner/observability-test/table.ts b/handwritten/spanner/observability-test/table.ts index 36257b34e875..5f76ba14bf59 100644 --- a/handwritten/spanner/observability-test/table.ts +++ b/handwritten/spanner/observability-test/table.ts @@ -18,7 +18,7 @@ import * as pfy from '@google-cloud/promisify'; import * as assert from 'assert'; import {before, beforeEach, afterEach, describe, it} from 'mocha'; import * as extend from 'extend'; -import * as proxyquire from 'proxyquire'; +import {proxyquire} from 'google-test-utils'; import * as sinon from 'sinon'; import * as through from 'through2'; diff --git a/handwritten/spanner/observability-test/transaction.ts b/handwritten/spanner/observability-test/transaction.ts index 126b52141b8c..642e1066b1b3 100644 --- a/handwritten/spanner/observability-test/transaction.ts +++ b/handwritten/spanner/observability-test/transaction.ts @@ -17,7 +17,7 @@ import * as assert from 'assert'; import {before, beforeEach, afterEach, describe, it} from 'mocha'; import {EventEmitter} from 'events'; -import * as proxyquire from 'proxyquire'; +import {proxyquire} from 'google-test-utils'; import * as sinon from 'sinon'; import {codec} from '../src/codec'; diff --git a/handwritten/spanner/package.json b/handwritten/spanner/package.json index 321f691c5abd..73c4fd52dd97 100644 --- a/handwritten/spanner/package.json +++ b/handwritten/spanner/package.json @@ -35,9 +35,9 @@ "predocs": "pnpm run compile", "lint": "gts check", "system-test": "node ../../bin/run-test.cjs build/system-test --timeout 1600000", - "observability-test": "node ../../bin/run-test.cjs --proxyquire-shim build/observability-test --timeout 1600000", + "observability-test": "node ../../bin/run-test.cjs build/observability-test --timeout 1600000", "cleanup": "node ../../bin/run-test.cjs scripts/cleanup.js --timeout 30000", - "test": "node ../../bin/run-test.cjs --proxyquire-shim build/test build/test/common build/observability-test", + "test": "node ../../bin/run-test.cjs build/test build/test/common build/observability-test", "ycsb": "node ./benchmark/ycsb.js run -P ./benchmark/workloada -p table=usertable -p cloudspanner.instance=ycsb-instance -p operationcount=100 -p cloudspanner.database=ycsb", "fix": "gts fix", "clean": "gts clean", @@ -107,7 +107,7 @@ "dedent": "^1.5.3", "execa": "^5.0.0", "gapic-tools": "^2.2.0", - "google-test-utils": "^0.3.0", + "google-test-utils": "^0.4.0", "grpc-health-check": "^2.1.0", "gts": "^6.0.2", "jsdoc": "^4.0.4", diff --git a/handwritten/spanner/test/backup.ts b/handwritten/spanner/test/backup.ts index f52acc976b1b..9ef283045d36 100644 --- a/handwritten/spanner/test/backup.ts +++ b/handwritten/spanner/test/backup.ts @@ -17,7 +17,7 @@ import * as assert from 'assert'; import {EventEmitter} from 'events'; -import * as proxyquire from 'proxyquire'; +import {proxyquire} from 'google-test-utils'; import * as sinon from 'sinon'; import {util} from '@google-cloud/common'; import * as pfy from '@google-cloud/promisify'; diff --git a/handwritten/spanner/test/batch-transaction.ts b/handwritten/spanner/test/batch-transaction.ts index 990bee6bb8bd..d9945b34d615 100644 --- a/handwritten/spanner/test/batch-transaction.ts +++ b/handwritten/spanner/test/batch-transaction.ts @@ -20,7 +20,7 @@ import {util} from '@google-cloud/common'; import * as pfy from '@google-cloud/promisify'; import * as assert from 'assert'; import {before, beforeEach, afterEach, describe, it} from 'mocha'; -import * as proxyquire from 'proxyquire'; +import {proxyquire} from 'google-test-utils'; import * as sinon from 'sinon'; import {Session, Database, Spanner, protos} from '../src'; diff --git a/handwritten/spanner/test/common/service-object.ts b/handwritten/spanner/test/common/service-object.ts index 7e5544eb8e95..208c3f148d39 100644 --- a/handwritten/spanner/test/common/service-object.ts +++ b/handwritten/spanner/test/common/service-object.ts @@ -19,7 +19,7 @@ import * as pfy from '@google-cloud/promisify'; import * as assert from 'assert'; import {before, beforeEach, describe, it} from 'mocha'; import * as extend from 'extend'; -import * as proxyquire from 'proxyquire'; +import {proxyquire} from 'google-test-utils'; let promisified = false; const fakePfy = Object.assign({}, pfy, { diff --git a/handwritten/spanner/test/common/service.ts b/handwritten/spanner/test/common/service.ts index 11ea01a9820a..05fc2d0d0a58 100644 --- a/handwritten/spanner/test/common/service.ts +++ b/handwritten/spanner/test/common/service.ts @@ -20,7 +20,7 @@ import {before, beforeEach, after, afterEach, describe, it} from 'mocha'; import * as duplexify from 'duplexify'; import * as extend from 'extend'; import {grpc, GrpcClient} from 'google-gax'; -import * as proxyquire from 'proxyquire'; +import {proxyquire} from 'google-test-utils'; import * as retryRequest from 'retry-request'; import * as sn from 'sinon'; import {PassThrough} from 'stream'; diff --git a/handwritten/spanner/test/database.ts b/handwritten/spanner/test/database.ts index ea94628136e6..d5b66fae4bce 100644 --- a/handwritten/spanner/test/database.ts +++ b/handwritten/spanner/test/database.ts @@ -21,7 +21,7 @@ import {before, beforeEach, afterEach, describe, it} from 'mocha'; import {EventEmitter} from 'events'; import * as extend from 'extend'; import {ApiError, util} from '@google-cloud/common'; -import * as proxyquire from 'proxyquire'; +import {proxyquire} from 'google-test-utils'; import * as sinon from 'sinon'; import {Transform, Duplex} from 'stream'; import * as through from 'through2'; diff --git a/handwritten/spanner/test/index.ts b/handwritten/spanner/test/index.ts index 384eb8b5c440..ea9fa0c6ca9a 100644 --- a/handwritten/spanner/test/index.ts +++ b/handwritten/spanner/test/index.ts @@ -20,7 +20,7 @@ import * as assert from 'assert'; import {before, beforeEach, afterEach, describe, it} from 'mocha'; import * as extend from 'extend'; import * as path from 'path'; -import * as proxyquire from 'proxyquire'; +import {proxyquire} from 'google-test-utils'; import * as through from 'through2'; import {util} from '@google-cloud/common'; import {PreciseDate} from '@google-cloud/precise-date'; diff --git a/handwritten/spanner/test/instance-config.ts b/handwritten/spanner/test/instance-config.ts index dd050be447f0..b755ff8033b4 100644 --- a/handwritten/spanner/test/instance-config.ts +++ b/handwritten/spanner/test/instance-config.ts @@ -18,7 +18,7 @@ import * as assert from 'assert'; import {before, beforeEach, afterEach, describe, it} from 'mocha'; import {grpc} from 'google-gax'; -import * as proxyquire from 'proxyquire'; +import {proxyquire} from 'google-test-utils'; import * as pfy from '@google-cloud/promisify'; import * as sinon from 'sinon'; diff --git a/handwritten/spanner/test/instance.ts b/handwritten/spanner/test/instance.ts index f816e2fa0d15..263d9bb9621f 100644 --- a/handwritten/spanner/test/instance.ts +++ b/handwritten/spanner/test/instance.ts @@ -20,7 +20,7 @@ import * as assert from 'assert'; import {before, beforeEach, afterEach, describe, it} from 'mocha'; import {ApiError} from '@google-cloud/common'; import {grpc} from 'google-gax'; -import * as proxyquire from 'proxyquire'; +import {proxyquire} from 'google-test-utils'; import * as pfy from '@google-cloud/promisify'; import * as sinon from 'sinon'; import snakeCase = require('lodash.snakecase'); diff --git a/handwritten/spanner/test/partial-result-stream.ts b/handwritten/spanner/test/partial-result-stream.ts index 4d8560be7593..05d2fa8e1a45 100644 --- a/handwritten/spanner/test/partial-result-stream.ts +++ b/handwritten/spanner/test/partial-result-stream.ts @@ -19,7 +19,6 @@ import {before, beforeEach, afterEach, describe, it} from 'mocha'; // eslint-disable-next-line @typescript-eslint/no-var-requires // eslint-disable-next-line @typescript-eslint/no-var-requires const concat = require('concat-stream'); -import * as proxyquire from 'proxyquire'; import * as sinon from 'sinon'; import {Transform, finished} from 'stream'; import * as through from 'through2'; @@ -28,7 +27,7 @@ import {codec} from '../src/codec'; import {PreciseDate} from '@google-cloud/precise-date'; import * as prs from '../src/partial-result-stream'; import {grpc} from 'google-gax'; -import {assertArraySubclassStrictEqual} from 'google-test-utils'; +import {assertArraySubclassStrictEqual, proxyquire} from 'google-test-utils'; import {Row} from '../src/partial-result-stream'; function toRawValue(value: any): any { diff --git a/handwritten/spanner/test/session.ts b/handwritten/spanner/test/session.ts index 60e2de6845a6..6e8e48c36afc 100644 --- a/handwritten/spanner/test/session.ts +++ b/handwritten/spanner/test/session.ts @@ -19,7 +19,7 @@ import * as pfy from '@google-cloud/promisify'; import * as assert from 'assert'; import {before, beforeEach, describe, it} from 'mocha'; -import * as proxyquire from 'proxyquire'; +import {proxyquire} from 'google-test-utils'; import { CLOUD_RESOURCE_HEADER, LEADER_AWARE_ROUTING_HEADER, diff --git a/handwritten/spanner/test/table.ts b/handwritten/spanner/test/table.ts index 199d456215ba..b492b7a8d7a2 100644 --- a/handwritten/spanner/test/table.ts +++ b/handwritten/spanner/test/table.ts @@ -17,7 +17,7 @@ import * as pfy from '@google-cloud/promisify'; import * as assert from 'assert'; import {before, beforeEach, afterEach, describe, it} from 'mocha'; -import * as proxyquire from 'proxyquire'; +import {proxyquire} from 'google-test-utils'; import * as sinon from 'sinon'; import {Transform} from 'stream'; import * as through from 'through2'; diff --git a/handwritten/spanner/test/transaction-runner.ts b/handwritten/spanner/test/transaction-runner.ts index 9a2bd818b313..d258340da1d3 100644 --- a/handwritten/spanner/test/transaction-runner.ts +++ b/handwritten/spanner/test/transaction-runner.ts @@ -18,7 +18,7 @@ import * as assert from 'assert'; import {before, beforeEach, afterEach, describe, it} from 'mocha'; import {EventEmitter} from 'events'; import {grpc} from 'google-gax'; -import * as proxyquire from 'proxyquire'; +import {proxyquire} from 'google-test-utils'; import * as sinon from 'sinon'; import * as through from 'through2'; import {RunTransactionOptions} from '../src/transaction-runner'; @@ -329,6 +329,7 @@ describe('TransactionRunner', () => { runner .run() + // eslint-disable-next-line promise/always-return .then(() => { done(new Error('missing expected DEADLINE_EXCEEDED error')); }) diff --git a/handwritten/spanner/test/transaction.ts b/handwritten/spanner/test/transaction.ts index 5e5e13ef7590..55706e14605c 100644 --- a/handwritten/spanner/test/transaction.ts +++ b/handwritten/spanner/test/transaction.ts @@ -19,7 +19,7 @@ import * as assert from 'assert'; import {before, beforeEach, afterEach, describe, it} from 'mocha'; import {EventEmitter} from 'events'; import {common as p} from 'protobufjs'; -import * as proxyquire from 'proxyquire'; +import {proxyquire} from 'google-test-utils'; import * as sinon from 'sinon'; import {codec} from '../src/codec'; diff --git a/handwritten/storage/package.json b/handwritten/storage/package.json index 5f86c070b243..3d51b0073ce8 100644 --- a/handwritten/storage/package.json +++ b/handwritten/storage/package.json @@ -71,7 +71,7 @@ "pretest": "pnpm run compile --sourceMap", "system-test:esm": "mkdir -p $HOME/.config && node ../../bin/run-test.cjs --no-parallel build/esm/system-test --timeout 600000 --exit", "system-test": "mkdir -p $HOME/.config && node ../../bin/run-test.cjs --no-parallel build/cjs/system-test --timeout 600000 --exit", - "test": "cross-env NODE_OPTIONS=\"--require ./scripts/preload-yargs.cjs --no-deprecation\" node ../../bin/run-test.cjs --proxyquire-shim build/cjs/test" + "test": "cross-env NODE_OPTIONS=\"--require ./scripts/preload-yargs.cjs --no-deprecation\" node ../../bin/run-test.cjs build/cjs/test" }, "dependencies": { "@google-cloud/paginator": "^7.2.0", @@ -110,6 +110,7 @@ "cross-env": "^7.0.3", "form-data": "^4.0.4", "gapic-tools": "^2.2.0", + "google-test-utils": "^0.4.0", "gts": "^5.0.0", "jsdoc": "^4.0.4", "jsdoc-fresh": "^6.1.0", diff --git a/handwritten/storage/test/acl.ts b/handwritten/storage/test/acl.ts index 5c1d73e25ae0..ba6c7d876ceb 100644 --- a/handwritten/storage/test/acl.ts +++ b/handwritten/storage/test/acl.ts @@ -15,7 +15,7 @@ import {DecorateRequestOptions, util} from '../src/nodejs-common/index.js'; import assert from 'assert'; import {describe, it, before, beforeEach} from 'mocha'; -import proxyquire from 'proxyquire'; +import {proxyquire} from 'google-test-utils'; import {Storage} from '../src/storage.js'; // eslint-disable-next-line @typescript-eslint/no-explicit-any diff --git a/handwritten/storage/test/bucket.ts b/handwritten/storage/test/bucket.ts index 09928da7aab4..91eafa1e2263 100644 --- a/handwritten/storage/test/bucket.ts +++ b/handwritten/storage/test/bucket.ts @@ -26,7 +26,7 @@ import {describe, it, before, beforeEach, after, afterEach} from 'mocha'; import mime from 'mime'; import pLimit from 'p-limit'; import * as path from 'path'; -import proxyquire from 'proxyquire'; +import {proxyquire} from 'google-test-utils'; import * as stream from 'stream'; import {Bucket, Channel, Notification, CRC32C} from '../src/index.js'; diff --git a/handwritten/storage/test/channel.ts b/handwritten/storage/test/channel.ts index e70272f20453..b9c5039d1599 100644 --- a/handwritten/storage/test/channel.ts +++ b/handwritten/storage/test/channel.ts @@ -24,7 +24,7 @@ import { } from '../src/nodejs-common/index.js'; import assert from 'assert'; import {describe, it, before, beforeEach} from 'mocha'; -import proxyquire from 'proxyquire'; +import {proxyquire} from 'google-test-utils'; let promisified = false; const fakePromisify = { diff --git a/handwritten/storage/test/file.ts b/handwritten/storage/test/file.ts index 938e8e317bba..962bf4dbad78 100644 --- a/handwritten/storage/test/file.ts +++ b/handwritten/storage/test/file.ts @@ -36,7 +36,7 @@ import * as crypto from 'crypto'; import duplexify from 'duplexify'; import * as fs from 'fs'; import * as path from 'path'; -import proxyquire from 'proxyquire'; +import {proxyquire} from 'google-test-utils'; import * as resumableUpload from '../src/resumable-upload.js'; import * as sinon from 'sinon'; import * as tmp from 'tmp'; diff --git a/handwritten/storage/test/headers.ts b/handwritten/storage/test/headers.ts index b786ae54d4e0..fc1f437c4a97 100644 --- a/handwritten/storage/test/headers.ts +++ b/handwritten/storage/test/headers.ts @@ -14,7 +14,7 @@ import * as assert from 'assert'; import {describe, it} from 'mocha'; -import proxyquire from 'proxyquire'; +import {proxyquire} from 'google-test-utils'; const error = Error('not implemented'); diff --git a/handwritten/storage/test/hmacKey.ts b/handwritten/storage/test/hmacKey.ts index b67da92d7233..f8a3da7e723b 100644 --- a/handwritten/storage/test/hmacKey.ts +++ b/handwritten/storage/test/hmacKey.ts @@ -13,7 +13,7 @@ // limitations under the License. import * as sinon from 'sinon'; -import proxyquire from 'proxyquire'; +import {proxyquire} from 'google-test-utils'; import assert from 'assert'; import {describe, it, beforeEach, afterEach} from 'mocha'; import {util, ServiceObject} from '../src/nodejs-common/index.js'; diff --git a/handwritten/storage/test/iam.ts b/handwritten/storage/test/iam.ts index a037e77b0a46..d4b8440faf89 100644 --- a/handwritten/storage/test/iam.ts +++ b/handwritten/storage/test/iam.ts @@ -15,7 +15,7 @@ import {DecorateRequestOptions, util} from '../src/nodejs-common/index.js'; import assert from 'assert'; import {describe, it, before, beforeEach} from 'mocha'; -import proxyquire from 'proxyquire'; +import {proxyquire} from 'google-test-utils'; import {IAMExceptionMessages} from '../src/iam.js'; describe('storage/iam', () => { diff --git a/handwritten/storage/test/index.ts b/handwritten/storage/test/index.ts index f615cbeb1ffa..d3d8360fab7b 100644 --- a/handwritten/storage/test/index.ts +++ b/handwritten/storage/test/index.ts @@ -22,7 +22,7 @@ import { import {PromisifyAllOptions} from '@google-cloud/promisify'; import assert from 'assert'; import {describe, it, before, beforeEach, after, afterEach} from 'mocha'; -import proxyquire from 'proxyquire'; +import {proxyquire} from 'google-test-utils'; // eslint-disable-next-line @typescript-eslint/no-unused-vars import {Bucket, CRC32C_DEFAULT_VALIDATOR_GENERATOR} from '../src/index.js'; import {GetFilesOptions} from '../src/bucket.js'; diff --git a/handwritten/storage/test/nodejs-common/service-object.ts b/handwritten/storage/test/nodejs-common/service-object.ts index ac22a62dbdcf..159949ebe6e7 100644 --- a/handwritten/storage/test/nodejs-common/service-object.ts +++ b/handwritten/storage/test/nodejs-common/service-object.ts @@ -21,7 +21,7 @@ import { } from '@google-cloud/promisify'; import assert from 'assert'; import {describe, it, beforeEach, afterEach} from 'mocha'; -import proxyquire from 'proxyquire'; +import {proxyquire} from 'google-test-utils'; import type { OptionsWithUri, Request as TeenyRequest, diff --git a/handwritten/storage/test/nodejs-common/service.ts b/handwritten/storage/test/nodejs-common/service.ts index f785a1315793..131dcbf4122f 100644 --- a/handwritten/storage/test/nodejs-common/service.ts +++ b/handwritten/storage/test/nodejs-common/service.ts @@ -16,7 +16,7 @@ import assert from 'assert'; import {describe, it, before, beforeEach, after} from 'mocha'; -import proxyquire from 'proxyquire'; +import {proxyquire} from 'google-test-utils'; import {Request} from 'teeny-request'; import {AuthClient, GoogleAuth, OAuth2Client} from 'google-auth-library'; diff --git a/handwritten/storage/test/nodejs-common/util.ts b/handwritten/storage/test/nodejs-common/util.ts index d7ebc515c3fb..e764734227e7 100644 --- a/handwritten/storage/test/nodejs-common/util.ts +++ b/handwritten/storage/test/nodejs-common/util.ts @@ -27,7 +27,7 @@ import { OAuth2Client, } from 'google-auth-library'; import * as nock from 'nock'; -import proxyquire from 'proxyquire'; +import {proxyquire} from 'google-test-utils'; import retryRequest from 'retry-request'; import * as sinon from 'sinon'; import * as stream from 'stream'; diff --git a/handwritten/storage/test/notification.ts b/handwritten/storage/test/notification.ts index fe396dcb512a..f562ec14fd92 100644 --- a/handwritten/storage/test/notification.ts +++ b/handwritten/storage/test/notification.ts @@ -21,7 +21,7 @@ import { } from '../src/nodejs-common/index.js'; import assert from 'assert'; import {describe, it, before, beforeEach} from 'mocha'; -import proxyquire from 'proxyquire'; +import {proxyquire} from 'google-test-utils'; import {Bucket} from '../src/index.js'; diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index cc39c859dfde..82d0ac446531 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -129,6 +129,9 @@ importers: codecov: specifier: ^3.8.3 version: 3.8.3(encoding@0.1.13) + google-test-utils: + specifier: ^0.4.0 + version: 0.4.0 gts: specifier: ^6.0.2 version: 6.0.2(typescript@5.9.3) @@ -1659,6 +1662,9 @@ importers: eslint-plugin-prettier: specifier: ^5.2.6 version: 5.5.6(eslint-config-prettier@9.1.2(eslint@8.57.1))(eslint@8.57.1)(prettier@3.9.6) + google-test-utils: + specifier: ^0.4.0 + version: 0.4.0 gts: specifier: ^6.0.2 version: 6.0.2(typescript@5.9.3) @@ -1925,6 +1931,9 @@ importers: gapic-tools: specifier: ^2.2.0 version: 2.2.0(protobufjs@8.8.0) + google-test-utils: + specifier: ^0.4.0 + version: 0.4.0 gts: specifier: ^6.0.2 version: 6.0.2(typescript@5.9.3) @@ -2170,6 +2179,9 @@ importers: gapic-tools: specifier: ^2.2.0 version: 2.2.0(protobufjs@7.5.9) + google-test-utils: + specifier: ^0.4.0 + version: 0.4.0 gts: specifier: ^6.0.2 version: 6.0.2(typescript@5.9.3) @@ -2512,6 +2524,9 @@ importers: codecov: specifier: ^3.8.3 version: 3.8.3(encoding@0.1.13) + google-test-utils: + specifier: ^0.4.0 + version: 0.4.0 gts: specifier: ^6.0.2 version: 6.0.2(typescript@5.9.3) @@ -2657,6 +2672,9 @@ importers: gapic-tools: specifier: ^2.2.0 version: 2.2.0(protobufjs@8.8.0) + google-test-utils: + specifier: ^0.4.0 + version: 0.4.0 gts: specifier: ^5.0.0 version: 5.3.1(typescript@5.9.3) @@ -2754,6 +2772,9 @@ importers: express: specifier: ^4.16.3 version: 4.22.2 + google-test-utils: + specifier: ^0.4.0 + version: 0.4.0 gts: specifier: ^6.0.2 version: 6.0.2(typescript@5.9.3) @@ -2821,6 +2842,9 @@ importers: cross-env: specifier: ^7.0.3 version: 7.0.3 + google-test-utils: + specifier: ^0.4.0 + version: 0.4.0 gts: specifier: ^6.0.2 version: 6.0.2(typescript@5.9.3) @@ -2964,8 +2988,8 @@ importers: specifier: ^2.2.0 version: 2.2.0(protobufjs@7.5.9) google-test-utils: - specifier: ^0.3.0 - version: 0.3.1 + specifier: ^0.4.0 + version: 0.4.0 gts: specifier: ^6.0.0 version: 6.0.2(typescript@5.9.3) @@ -3193,8 +3217,8 @@ importers: specifier: ^2.2.0 version: 2.2.0(protobufjs@7.5.9) google-test-utils: - specifier: ^0.3.0 - version: 0.3.1 + specifier: ^0.4.0 + version: 0.4.0 grpc-health-check: specifier: ^2.1.0 version: 2.1.0 @@ -3411,6 +3435,9 @@ importers: gapic-tools: specifier: ^2.2.0 version: 2.2.0(protobufjs@8.8.0) + google-test-utils: + specifier: ^0.4.0 + version: 0.4.0 gts: specifier: ^5.0.0 version: 5.3.1(typescript@5.9.3) @@ -20556,8 +20583,8 @@ packages: resolution: {integrity: sha512-UD8I3vdspFSKFu8yi48sgeXDXcET0CAPYbSK7G2oRh7G1Y+BEG8VKDY3r+0GXF8KmHhQWhygRLVxY0lgTGeySA==} engines: {node: '>=22'} - google-test-utils@0.3.1: - resolution: {integrity: sha512-lyoeWglF387Kfdd7zw8tuKS0GWlF/lNknoUmK08TdncVeOyHtTV9HKzgScVt1JrQsvx5qT7tihmXJSYVwbLZaA==} + google-test-utils@0.4.0: + resolution: {integrity: sha512-MMlNdyzy/i51cJXqjgzqgvu7qR1uNierj2+bZj1hMoJixJBEdnw51XuVjLu5n6DsKGo1dVbUI0UyU9OP8nYgdg==} engines: {node: '>=22'} googleapis-common@4.4.3: @@ -31107,7 +31134,7 @@ snapshots: protobufjs: 7.5.9 walkdir: 0.4.1 - google-test-utils@0.3.1: {} + google-test-utils@0.4.0: {} googleapis-common@4.4.3(encoding@0.1.13): dependencies: