diff --git a/handwritten/bigtable/cloudbuild.yaml b/handwritten/bigtable/cloudbuild.yaml index ef5dbbc30c9b..2fdae9239f34 100644 --- a/handwritten/bigtable/cloudbuild.yaml +++ b/handwritten/bigtable/cloudbuild.yaml @@ -5,7 +5,7 @@ steps: args: - '-c' - | - cd ../.. && corepack enable pnpm && pnpm install --filter "...{./handwritten/bigtable}" + cd ../.. && corepack enable pnpm && pnpm install --filter "./core/test-utils" --filter "...{./handwritten/bigtable}" --ignore-scripts && pnpm --dir core/test-utils run compile && node -e "require('./bin/run-test.cjs').ensureWorkspacePackagesLinked()" && pnpm --filter "...{./handwritten/bigtable}" run prepare --if-present dir: 'handwritten/bigtable' id: 'install-dependencies' diff --git a/handwritten/bigtable/package.json b/handwritten/bigtable/package.json index fab4e307fa9b..e04716e47092 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.0.0", + "google-test-utils": "^0.3.0", "gts": "^6.0.2", "jsdoc": "^4.0.4", "jsdoc-fresh": "^6.0.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 d0d8d9ebe49b..d1458e07d1a9 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 7a029b37378e..deb3254b6579 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 7446126bff45..d9903a1afe75 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 ca1f444cfb65..e03bfb56ffc8 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 * as rw from '../src/row'; diff --git a/handwritten/bigtable/test/table.ts b/handwritten/bigtable/test/table.ts index c10e89145d4e..6406de9e25e9 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/spanner/cloudbuild.yaml b/handwritten/spanner/cloudbuild.yaml index 5ac1335ff111..fe987edf9c5f 100644 --- a/handwritten/spanner/cloudbuild.yaml +++ b/handwritten/spanner/cloudbuild.yaml @@ -5,7 +5,7 @@ steps: args: - '-c' - | - cd ../.. && corepack enable pnpm && pnpm install --filter "...{./handwritten/spanner}" + cd ../.. && corepack enable pnpm && pnpm install --filter "./core/test-utils" --filter "...{./handwritten/spanner}" --ignore-scripts && pnpm --dir core/test-utils run compile && node -e "require('./bin/run-test.cjs').ensureWorkspacePackagesLinked()" && pnpm --filter "...{./handwritten/spanner}" run prepare --if-present dir: 'handwritten/spanner' id: 'install-dependencies' 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 e07b4ae6b71c..04702a7dc5c6 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.0.0", - "google-test-utils": "^0.2.0", + "google-test-utils": "^0.3.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/cloudbuild.yaml b/handwritten/storage/cloudbuild.yaml index c0d5e374ea4a..57e5f1eb1536 100644 --- a/handwritten/storage/cloudbuild.yaml +++ b/handwritten/storage/cloudbuild.yaml @@ -5,7 +5,7 @@ steps: args: - '-c' - | - cd ../.. && corepack enable pnpm && pnpm install --filter "...{./handwritten/storage}" + cd ../.. && corepack enable pnpm && pnpm install --filter "./core/test-utils" --filter "...{./handwritten/storage}" --ignore-scripts && pnpm --dir core/test-utils run compile && node -e "require('./bin/run-test.cjs').ensureWorkspacePackagesLinked()" && pnpm --filter "...{./handwritten/storage}" run prepare --if-present dir: 'handwritten/storage' id: 'install-dependencies' diff --git a/handwritten/storage/package.json b/handwritten/storage/package.json index 461391690a21..ee196e30138c 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.0.1", @@ -110,6 +110,7 @@ "cross-env": "^7.0.3", "form-data": "^4.0.4", "gapic-tools": "^2.0.1", + "google-test-utils": "^0.3.0", "gts": "^5.0.0", "jsdoc": "^4.0.4", "jsdoc-fresh": "^6.0.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 d3e796667663..5cc7e10574bf 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -1934,6 +1934,9 @@ importers: gapic-tools: specifier: ^2.0.0 version: 2.0.1(protobufjs@8.8.0) + google-test-utils: + specifier: ^0.3.0 + version: 0.3.0 gts: specifier: ^6.0.2 version: 6.0.2(typescript@5.9.3) @@ -3217,8 +3220,8 @@ importers: specifier: ^2.0.0 version: 2.0.1(protobufjs@7.5.9) google-test-utils: - specifier: ^0.2.0 - version: 0.2.0 + specifier: ^0.3.0 + version: 0.3.0 grpc-health-check: specifier: ^2.1.0 version: 2.1.0 @@ -3435,6 +3438,9 @@ importers: gapic-tools: specifier: ^2.0.1 version: 2.0.1(protobufjs@8.8.0) + google-test-utils: + specifier: ^0.3.0 + version: 0.3.0 gts: specifier: ^5.0.0 version: 5.3.1(typescript@5.9.3) @@ -20775,10 +20781,6 @@ packages: resolution: {integrity: sha512-fbvUWVNh3rKGlVFWwlUNF7Sk1Tah0a89q02rLTXsWjbKKHGeuURAa8tl9rvu5TyWny1YiSIo5eDqF260Tai6vQ==} engines: {node: '>=22'} - google-test-utils@0.2.0: - resolution: {integrity: sha512-OP7B5iS65EjAlRctfq3uUdGWXN5AvIGRYQSx5luCVqkfh3uaGvVzuY1y3hCyxLk6MGf5DYkJ3rZxgJ6JsMmSog==} - engines: {node: '>=22'} - google-test-utils@0.3.0: resolution: {integrity: sha512-atGLcriC2MS6gWCJnCNrxLqYh4Xs5WkgaS9+lwxF/3rZdzt5eFv/Bc2VIeCCl5DGzGP3So8dj5f7pfBUNRhzXw==} engines: {node: '>=22'} @@ -32065,8 +32067,6 @@ snapshots: protobufjs: 7.5.9 walkdir: 0.4.1 - google-test-utils@0.2.0: {} - google-test-utils@0.3.0: {} googleapis-common@4.4.3(encoding@0.1.13):