Skip to content

Commit

Permalink
chore: replace repo tools tools.runAsync function with execSync (#1597)
Browse files Browse the repository at this point in the history
  • Loading branch information
sofisl authored Feb 3, 2020
1 parent cab0d56 commit 9631b11
Show file tree
Hide file tree
Showing 26 changed files with 327 additions and 326 deletions.
10 changes: 5 additions & 5 deletions auth/system-test/auth.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

const path = require('path');
const assert = require('assert');
const tools = require('@google-cloud/nodejs-repo-tools');
const {execSync} = require('child_process');

const cwd = path.join(__dirname, '..');
const cmd = 'node auth.js';
Expand All @@ -34,16 +34,16 @@ before(() => {
);
});

it('should load credentials implicitly', async () => {
const output = await tools.runAsync(`${cmd} auth-cloud-implicit`, cwd);
it('should load credentials implicitly', () => {
const output = execSync(`${cmd} auth-cloud-implicit`, cwd);
assert.strictEqual(output.includes(BUCKET_NAME), true);
});

it('should load credentials explicitly', async () => {
it('should load credentials explicitly', () => {
const project = process.env.GCLOUD_PROJECT;
const keyfile = process.env.GOOGLE_APPLICATION_CREDENTIALS;
console.log(`${cmd} auth-cloud-explicit -p ${project} -k ${keyfile}`);
const output = await tools.runAsync(
const output = execSync(
`${cmd} auth-cloud-explicit -p ${project} -k ${keyfile}`,
cwd
);
Expand Down
20 changes: 10 additions & 10 deletions endpoints/getting-started-grpc/system-test/endpoints.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,16 +72,16 @@ const JWT_AUTH_TOKEN = jwt.sign(
);

// API key
it(`should request a greeting from a remote Compute Engine instance using an API key`, async () => {
const output = await tools.runAsync(
it(`should request a greeting from a remote Compute Engine instance using an API key`, () => {
const output = childProcess.execSync(
`${clientCmd} -h ${GCE_HOST} -k ${API_KEY}`,
cwd
);
assert.ok(new RegExp('Hello world').test(output));
});

it(`should request a greeting from a remote Container Engine cluster using an API key`, async () => {
const output = await tools.runAsync(
it(`should request a greeting from a remote Container Engine cluster using an API key`, () => {
const output = childProcess.execSync(
`${clientCmd} -h ${GKE_HOST} -k ${API_KEY}`,
cwd
);
Expand All @@ -93,7 +93,7 @@ it('should request and handle a greeting locally using an API key', async () =>
const server = childProcess.exec(`${serverCmd} -p ${PORT}`, {cwd: cwd});

await delay(1000);
const clientOutput = await tools.runAsync(
const clientOutput = childProcess.execSync(
`${clientCmd} -h localhost:${PORT} -k ${API_KEY}`,
cwd
);
Expand All @@ -102,16 +102,16 @@ it('should request and handle a greeting locally using an API key', async () =>
});

// Authtoken
it(`should request a greeting from a remote Compute Engine instance using a JWT Auth Token`, async () => {
const output = await tools.runAsync(
it(`should request a greeting from a remote Compute Engine instance using a JWT Auth Token`, () => {
const output = childProcess.execSync(
`${clientCmd} -h ${GCE_HOST} -j ${JWT_AUTH_TOKEN}`,
cwd
);
assert.ok(new RegExp('Hello world').test(output));
});

it(`should request a greeting from a remote Container Engine cluster using a JWT Auth Token`, async () => {
const output = await tools.runAsync(
it(`should request a greeting from a remote Container Engine cluster using a JWT Auth Token`, () => {
const output = childProcess.execSync(
`${clientCmd} -h ${GKE_HOST} -j ${JWT_AUTH_TOKEN}`,
cwd
);
Expand All @@ -123,7 +123,7 @@ it(`should request and handle a greeting locally using a JWT Auth Token`, async
const server = childProcess.exec(`${serverCmd} -p ${PORT}`, {cwd: cwd});

await delay(1000);
const clientOutput = await tools.runAsync(
const clientOutput = childProcess.execSync(
`${clientCmd} -h localhost:${PORT} -j ${JWT_AUTH_TOKEN}`,
cwd
);
Expand Down
36 changes: 18 additions & 18 deletions healthcare/datasets/system-test/datasets.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@

const path = require('path');
const assert = require('assert');
const tools = require('@google-cloud/nodejs-repo-tools');
const uuid = require('uuid');
const {execSync} = require('child_process');

const cwd = path.join(__dirname, '..');
const projectId = process.env.GCLOUD_PROJECT;
Expand All @@ -36,35 +36,35 @@ before(() => {
`Must set GOOGLE_APPLICATION_CREDENTIALS environment variable!`
);
});
after(async () => {
after(() => {
try {
await tools.runAsync(
execSync(
`node deleteDataset.js ${projectId} ${cloudRegion} ${destinationDatasetId}`,
cwd
);
// eslint-disable-next-line no-empty
} catch (err) {} // Ignore error
});

it('should create a dataset', async () => {
const output = await tools.runAsync(
it('should create a dataset', () => {
const output = execSync(
`node createDataset.js ${projectId} ${cloudRegion} ${datasetId}`,
cwd
);
assert.strictEqual(output, `Created dataset: ${datasetId}`);
});

it('should get a dataset', async () => {
const output = await tools.runAsync(
it('should get a dataset', () => {
const output = execSync(
`node getDataset.js ${projectId} ${cloudRegion} ${datasetId}`,
cwd
);
assert.ok(output.includes('name'));
});

it('should patch a dataset', async () => {
it('should patch a dataset', () => {
const timeZone = 'GMT';
const output = await tools.runAsync(
const output = execSync(
`node patchDataset.js ${projectId} ${cloudRegion} ${datasetId} ${timeZone}`,
cwd
);
Expand All @@ -74,16 +74,16 @@ it('should patch a dataset', async () => {
);
});

it('should list datasets', async () => {
const output = await tools.runAsync(
it('should list datasets', () => {
const output = execSync(
`node listDatasets.js ${projectId} ${cloudRegion}`,
cwd
);
assert.ok(output.includes('datasets'));
});

it('should de-identify data in a dataset and write to a new dataset', async () => {
const output = await tools.runAsync(
it('should de-identify data in a dataset and write to a new dataset', () => {
const output = execSync(
`node deidentifyDataset.js ${projectId} ${cloudRegion} ${datasetId} ${destinationDatasetId} ${keeplistTags}`,
cwd
);
Expand All @@ -93,24 +93,24 @@ it('should de-identify data in a dataset and write to a new dataset', async () =
);
});

it('should create and get a dataset IAM policy', async () => {
it('should create and get a dataset IAM policy', () => {
const localMember = 'group:dpebot@google.com';
const localRole = 'roles/viewer';

let output = await tools.runAsync(
let output = execSync(
`node setDatasetIamPolicy.js ${projectId} ${cloudRegion} ${datasetId} ${localMember} ${localRole}`,
cwd
);
assert.ok(output.includes, 'ETAG');

output = await tools.runAsync(
output = execSync(
`node getDatasetIamPolicy.js ${projectId} ${cloudRegion} ${datasetId}`
);
assert.ok(output.includes('dpebot'));
});

it('should delete a dataset', async () => {
const output = await tools.runAsync(
it('should delete a dataset', () => {
const output = execSync(
`node deleteDataset.js ${projectId} ${cloudRegion} ${datasetId}`,
cwd
);
Expand Down
40 changes: 20 additions & 20 deletions healthcare/dicom/system-test/dicom_stores.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@

const path = require('path');
const assert = require('assert');
const tools = require('@google-cloud/nodejs-repo-tools');
const uuid = require('uuid');
const {execSync} = require('child_process');

const {PubSub} = require('@google-cloud/pubsub');
const {Storage} = require('@google-cloud/storage');
Expand Down Expand Up @@ -59,7 +59,7 @@ before(async () => {
// Create a Pub/Sub topic to be used for testing.
const [topic] = await pubSubClient.createTopic(topicName);
console.log(`Topic ${topic.name} created.`);
await tools.runAsync(
execSync(
`node createDataset.js ${projectId} ${cloudRegion} ${datasetId}`,
cwdDatasets
);
Expand All @@ -75,79 +75,79 @@ after(async () => {

await pubSubClient.topic(topicName).delete();
console.log(`Topic ${topicName} deleted.`);
await tools.runAsync(
execSync(
`node deleteDataset.js ${projectId} ${cloudRegion} ${datasetId}`,
cwdDatasets
);
} catch (err) {} // Ignore error
});

it('should create a DICOM store', async () => {
const output = await tools.runAsync(
it('should create a DICOM store', () => {
const output = execSync(
`node createDicomStore.js ${projectId} ${cloudRegion} ${datasetId} ${dicomStoreId}`,
cwd
);
assert.ok(output.includes('Created DICOM store'));
});

it('should get a DICOM store', async () => {
const output = await tools.runAsync(
it('should get a DICOM store', () => {
const output = execSync(
`node getDicomStore.js ${projectId} ${cloudRegion} ${datasetId} ${dicomStoreId}`,
cwd
);
assert.ok(output.includes('name'));
});

it('should patch a DICOM store', async () => {
const output = await tools.runAsync(
it('should patch a DICOM store', () => {
const output = execSync(
`node patchDicomStore.js ${projectId} ${cloudRegion} ${datasetId} ${dicomStoreId} ${topicName}`,
cwd
);
assert.ok(output.includes('Patched DICOM store'));
});

it('should list DICOM stores', async () => {
const output = await tools.runAsync(
it('should list DICOM stores', () => {
const output = execSync(
`node listDicomStores.js ${projectId} ${cloudRegion} ${datasetId}`,
cwd
);
assert.ok(output.includes('dicomStores'));
});

it('should create and get a DICOM store IAM policy', async () => {
it('should create and get a DICOM store IAM policy', () => {
const localMember = 'group:dpebot@google.com';
const localRole = 'roles/viewer';

let output = await tools.runAsync(
let output = execSync(
`node setDicomStoreIamPolicy.js ${projectId} ${cloudRegion} ${datasetId} ${dicomStoreId} ${localMember} ${localRole}`,
cwd
);
assert.ok(output.includes, 'ETAG');

output = await tools.runAsync(
output = execSync(
`node getDicomStoreIamPolicy.js ${projectId} ${cloudRegion} ${datasetId} ${dicomStoreId}`
);
assert.ok(output.includes('dpebot'));
});

it('should import a DICOM object from GCS', async () => {
const output = await tools.runAsync(
it('should import a DICOM object from GCS', () => {
const output = execSync(
`node importDicomInstance.js ${projectId} ${cloudRegion} ${datasetId} ${dicomStoreId} ${gcsUri}`,
cwd
);
assert.ok(output.includes('Successfully imported DICOM instances'));
});

it('should export a DICOM instance', async () => {
const output = await tools.runAsync(
it('should export a DICOM instance', () => {
const output = execSync(
`node exportDicomInstanceGcs.js ${projectId} ${cloudRegion} ${datasetId} ${dicomStoreId} ${bucketName}`,
cwd
);
assert.ok(output.includes('Exported DICOM instances'));
});

it('should delete a DICOM store', async () => {
const output = await tools.runAsync(
it('should delete a DICOM store', () => {
const output = execSync(
`node deleteDicomStore.js ${projectId} ${cloudRegion} ${datasetId} ${dicomStoreId}`,
cwd
);
Expand Down
Loading

0 comments on commit 9631b11

Please sign in to comment.