Skip to content
Draft
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
d9d3533
chore: fix owlbot configs, regenerate
leahecole Mar 6, 2025
18d4978
Apply suggestions from code review
leahecole Mar 6, 2025
c5c4dd3
WIP - two different ways
leahecole Mar 13, 2025
a409018
don't overwrite handwritten methods
leahecole Mar 14, 2025
bf0ab0b
change to sync file read
leahecole Mar 14, 2025
7abe972
chore: periodic regen
leahecole Apr 11, 2025
46c760e
run postprocessor
leahecole Apr 11, 2025
2ad938d
upgrade dependencies to node 18
leahecole May 21, 2025
ba7faa6
Revert "upgrade dependencies to node 18"
leahecole May 21, 2025
0e9e8fb
periodic regeneration + update to node 18 on autogen branch
leahecole May 21, 2025
34f72a8
fix lint errors
leahecole May 21, 2025
f73bb08
more lint fixes
leahecole May 21, 2025
2385d37
WIP: adding some integration tests
leahecole Jul 2, 2025
893c64a
add some system tests, sync with autogen branch
leahecole Jul 3, 2025
d01155f
add comment with buganizer bug
leahecole Jul 7, 2025
7a840ab
resolve lint errors, fix header, remove todos
leahecole Jul 31, 2025
a667e1a
chore: fix owlbot configs, regenerate
leahecole Mar 6, 2025
2f531ff
Apply suggestions from code review
leahecole Mar 6, 2025
a02b40d
WIP - two different ways
leahecole Mar 13, 2025
1e37eef
don't overwrite handwritten methods
leahecole Mar 14, 2025
6ddcbe0
change to sync file read
leahecole Mar 14, 2025
bddc1a3
chore: periodic regen
leahecole Apr 11, 2025
339af43
run postprocessor
leahecole Apr 11, 2025
cc150cc
upgrade dependencies to node 18
leahecole May 21, 2025
f1a9475
Revert "upgrade dependencies to node 18"
leahecole May 21, 2025
fb0a2de
periodic regeneration + update to node 18 on autogen branch
leahecole May 21, 2025
65f5340
fix lint errors
leahecole May 21, 2025
5133fb8
more lint fixes
leahecole May 21, 2025
a2523bc
WIP: adding some integration tests
leahecole Jul 2, 2025
bb19a14
add some system tests, sync with autogen branch
leahecole Jul 3, 2025
93e7861
add comment with buganizer bug
leahecole Jul 7, 2025
b754e81
resolve lint errors, fix header, remove todos
leahecole Jul 31, 2025
98d2213
Merge branch 'add_system_tests' of github.com:leahecole/nodejs-bigque…
leahecole Aug 29, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
130 changes: 130 additions & 0 deletions system-test/datasets.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
// Copyright 2025 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

'use strict';

import * as protos from '../protos/protos';
import {BigQueryClient} from '../src';
import assert = require('assert');
const {randomUUID} = require('crypto');
import {GoogleError} from 'google-gax';

const GCLOUD_TESTS_PREFIX = 'nodejs_samples_tests';
const datasetId = `${GCLOUD_TESTS_PREFIX}_datasets_${randomUUID()}`.replace(
/-/gi,
'_',
);

// the GCLOUD_PROJECT environment variable is set as part of test harness setup
const projectId = process.env.GCLOUD_PROJECT;

describe('Datasets', () => {
before(async () => {
if (projectId === undefined) {
throw Error(
'GCLOUD_PROJECT must be defined as an environment variable before tests can be run',
);
}
});

beforeEach(async function () {
this.currentTest.retries(2);
});


describe('dataset creation', () => {
const usCentral1Bigquery = new BigQueryClient(
{},
{
opts: {
apiEndpoint: 'bigquery.us-central1.rep.googleapis.com',
},
},
);
const usCentral1DatasetId = datasetId + '_uscentral1';

after('clean up dataset creation tests', async () => {
const usCentral1Request = {
projectId: projectId,
datasetId: usCentral1DatasetId,
};
await usCentral1Bigquery.deleteDataset(usCentral1Request);
});

it('should create a dataset using a regional endpoint', async () => {
// Construct the dataset resource.
const dataset = {
datasetReference: {
datasetId: usCentral1DatasetId,
},
location: 'us-central1',
};

// Construct the request object.
const request = {
projectId: projectId,
dataset: dataset,
};
await usCentral1Bigquery.insertDataset(request);
const getRequest = {
projectId: projectId,
datasetId: usCentral1DatasetId,
};

// we have to typecast this because response can be void when getDataset is called synchronously
// it is safe to typecast here because we are calling asynchronously
const response = (await usCentral1Bigquery.getDataset(getRequest)) as [
protos.google.cloud.bigquery.v2.IDataset,
protos.google.cloud.bigquery.v2.IGetDatasetRequest | undefined,
{} | undefined,
];
assert.strictEqual(response[0].id, `${projectId}:${usCentral1DatasetId}`);
});

//TODO(coleleah): fix
//captured in b/429419330
it.skip('should fail to create a dataset using a different region from the client endpoint', async () => {
const usEast4DatasetId = datasetId + '_us-east4';

// Construct the dataset resource
// with a location that does not match the client
// which uses us-central1
const dataset = {
datasetReference: {
datasetId: usEast4DatasetId,
},
location: 'us-east4',
};

// Construct the request object.
const request = {
projectId: projectId,
dataset: dataset,
};
let error;
try {
await usCentral1Bigquery.insertDataset(request);
} catch (err: unknown) {
console.log(err);
error = err;
}
assert.notStrictEqual(error, null);

assert.strictEqual(
(error as GoogleError).message,
'Invalid storage region',
);
});
});
});
Loading