From 1cf415a6406722d64beac8774b8aabe8c47cc171 Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Tue, 7 Apr 2026 22:09:04 +0000 Subject: [PATCH] test(bigquery): parameterize system tests for picosecond support Wraps the BigQuery system tests in a parameterized function to run them both with and without the BIGQUERY_PICOSECOND_SUPPORT environment variable. Clients and resources are re-instantiated within a before hook to ensure the library picks up the environment changes for each run. The existing indentation is preserved to maintain a clean PR diff. Co-authored-by: danieljbruce <8935272+danieljbruce@users.noreply.github.com> --- handwritten/bigquery/system-test/bigquery.ts | 40 ++++++++++++++++---- 1 file changed, 33 insertions(+), 7 deletions(-) diff --git a/handwritten/bigquery/system-test/bigquery.ts b/handwritten/bigquery/system-test/bigquery.ts index 8a104d9d9db..c447bd39735 100644 --- a/handwritten/bigquery/system-test/bigquery.ts +++ b/handwritten/bigquery/system-test/bigquery.ts @@ -38,17 +38,39 @@ import { } from '../src'; import bq from '../src/types'; -const bigquery = new BigQuery(); -const storage = new Storage(); +let bigquery = new BigQuery(); +let storage = new Storage(); + +const runTests = (supportPicoseconds: boolean | undefined) => { + const label = supportPicoseconds ? 'with pico' : 'without pico'; + +describe(`BigQuery (${label})`, () => { + const originalValue = process.env.BIGQUERY_PICOSECOND_SUPPORT; + + let dataset = bigquery.dataset(generateName('dataset')); + let table = dataset.table(generateName('table')); + let bucket = storage.bucket(generateName('bucket')); + + before(() => { + if (supportPicoseconds === undefined) { + delete process.env.BIGQUERY_PICOSECOND_SUPPORT; + } else { + process.env.BIGQUERY_PICOSECOND_SUPPORT = 'true'; + } + bigquery = new BigQuery(); + storage = new Storage(); + dataset = bigquery.dataset(generateName('dataset')); + table = dataset.table(generateName('table')); + bucket = storage.bucket(generateName('bucket')); + }); + + after(() => { + process.env.BIGQUERY_PICOSECOND_SUPPORT = originalValue; + }); -describe('BigQuery', () => { const GCLOUD_TESTS_PREFIX = 'nodejs_bq_test'; const minCreationTime = Date.now().toString(); - const dataset = bigquery.dataset(generateName('dataset')); - const table = dataset.table(generateName('table')); - const bucket = storage.bucket(generateName('bucket')); - const query = 'SELECT url FROM `publicdata.samples.github_nested` LIMIT 100'; const SCHEMA = [ @@ -2390,3 +2412,7 @@ describe('BigQuery', () => { } } }); +}; + +runTests(true); +runTests(undefined);