Skip to content
Merged
Show file tree
Hide file tree
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
14 changes: 4 additions & 10 deletions healthcare/dicom/system-test/dicom_stores.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@ const {Storage} = require('@google-cloud/storage');

const bucketName = `nodejs-docs-samples-test-${uuid.v4()}`;
const cloudRegion = 'us-central1';
const projectId = process.env.GOOGLE_CLOUD_PROJECT;
const pubSubClient = new PubSub({projectId});
const pubSubClient = new PubSub();
const storage = new Storage();
const topicName = `nodejs-healthcare-test-topic-${uuid.v4()}`;

Expand All @@ -42,21 +41,16 @@ const dcmFileName = 'IM-0002-0001-JPEG-BASELINE.dcm';
const resourceFile = `resources/${dcmFileName}`;
const gcsUri = `${bucketName}/${dcmFileName}`;
const installDeps = 'npm install';
let projectId;

// Run npm install on datasets directory because modalities
// require bootstrapping datasets, and Kokoro needs to know
// to install dependencies from the datasets directory.
assert.ok(execSync(installDeps, {cwd: `${cwdDatasets}`, shell: true}));

before(async () => {
assert(
process.env.GOOGLE_CLOUD_PROJECT,
'Must set GOOGLE_CLOUD_PROJECT environment variable!'
);
assert(
process.env.GOOGLE_APPLICATION_CREDENTIALS,
'Must set GOOGLE_APPLICATION_CREDENTIALS environment variable!'
);
projectId = await storage.getProjectId();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this storage.getProjectId() just because the Storage client is being used in this file? As opposed to google.auth.getProjectId().

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup, it calls the same underlying method. I used storage.getProjectId() because we already had a storage client, and it just exposes the underlying auth method. This method is available on all client libraries.

console.log(`THE PROJECT ID IS ${projectId}`);
// Create a Cloud Storage bucket to be used for testing.
await storage.createBucket(bucketName);
console.log(`Bucket ${bucketName} created.`);
Expand Down
15 changes: 5 additions & 10 deletions healthcare/dicom/system-test/dicomweb.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@ const path = require('path');
const assert = require('assert');
const uuid = require('uuid');
const {execSync} = require('child_process');
const google = require('@googleapis/healthcare');

const projectId = process.env.GOOGLE_CLOUD_PROJECT;
let projectId;
const cloudRegion = 'us-central1';

const cwdDatasets = path.join(__dirname, '../../datasets');
Expand Down Expand Up @@ -49,15 +50,9 @@ const installDeps = 'npm install';
// to install dependencies from the datasets directory.
assert.ok(execSync(installDeps, {cwd: `${cwdDatasets}`, shell: true}));

before(() => {
assert(
process.env.GOOGLE_CLOUD_PROJECT,
'Must set GOOGLE_CLOUD_PROJECT environment variable!'
);
assert(
process.env.GOOGLE_APPLICATION_CREDENTIALS,
'Must set GOOGLE_APPLICATION_CREDENTIALS environment variable!'
);
before(async () => {
projectId = await google.auth.getProjectId();
console.log(`THE PROJECT ID IS ${projectId}`);
execSync(`node createDataset.js ${projectId} ${cloudRegion} ${datasetId}`, {
cwd: cwdDatasets,
});
Expand Down