Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: (tests) Use a filter to locate datasets used in tests. #177

Merged
merged 1 commit into from
Aug 28, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions system-test/bigquery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ const bigquery = new BigQuery();
const storage = require('@google-cloud/storage')();

describe('BigQuery', function() {
const GCLOUD_TESTS_PREFIX = 'gcloud_test_';
const GCLOUD_TESTS_PREFIX = 'nodejs_bq_test';

const dataset = bigquery.dataset(generateName('dataset'));
const table = dataset.table(generateName('table'));
Expand Down Expand Up @@ -98,8 +98,10 @@ describe('BigQuery', function() {
// Remove datasets created for the tests.
deleteDatasets,

// Create the test dataset.
dataset.create.bind(dataset),
// Create the test dataset with a label tagging this as a test run.
dataset.create.bind(dataset, {
labels: [{[GCLOUD_TESTS_PREFIX]: ''}]
}),

// Create the test table.
table.create.bind(table, {
Expand Down Expand Up @@ -1631,7 +1633,7 @@ describe('BigQuery', function() {
});

function generateName(resourceType) {
return (GCLOUD_TESTS_PREFIX + resourceType + '_' + uuid.v1()).replace(
return `${GCLOUD_TESTS_PREFIX}_${resourceType}_${uuid.v1()}`.replace(
/-/g,
'_'
);
Expand Down Expand Up @@ -1674,7 +1676,7 @@ describe('BigQuery', function() {
function deleteDatasets(callback) {
bigquery.getDatasets(
{
prefix: GCLOUD_TESTS_PREFIX,
filter: `labels.${GCLOUD_TESTS_PREFIX}`,
},
function(err, datasets) {
if (err) {
Expand Down