diff --git a/healthcare/datasets/package.json b/healthcare/datasets/package.json index 5c29cb9add..a360df018c 100644 --- a/healthcare/datasets/package.json +++ b/healthcare/datasets/package.json @@ -9,11 +9,11 @@ "node": ">=6.0.0" }, "scripts": { - "test": "ava -T 1m --verbose system-test/*.test.js" + "test": "mocha system-test/*.test.js --timeout=60000" }, "devDependencies": { "@google-cloud/nodejs-repo-tools": "^3.0.0", - "ava": "^0.25.0" + "mocha": "^5.2.0" }, "dependencies": { "googleapis": "^37.0.0", diff --git a/healthcare/datasets/system-test/datasets.test.js b/healthcare/datasets/system-test/datasets.test.js index c15f3d2f0f..d1f1979d9a 100644 --- a/healthcare/datasets/system-test/datasets.test.js +++ b/healthcare/datasets/system-test/datasets.test.js @@ -15,65 +15,66 @@ 'use strict'; -const path = require(`path`); -const test = require(`ava`); -const tools = require(`@google-cloud/nodejs-repo-tools`); -const uuid = require(`uuid`); +const path = require('path'); +const assert = require('assert'); +const tools = require('@google-cloud/nodejs-repo-tools'); +const uuid = require('uuid'); -const cmd = `node datasets.js`; -const cwd = path.join(__dirname, `..`); +const cmd = 'node datasets.js'; +const cwd = path.join(__dirname, '..'); const datasetId = `dataset-${uuid.v4()}`.replace(/-/gi, '_'); const destinationDatasetId = `destination-${uuid.v4()}`.replace(/-/gi, '_'); const keeplistTags = 'PatientID'; -test.before(tools.checkCredentials); -test.after.always(async () => { +before(tools.checkCredentials); +after(async () => { try { await tools.runAsync(`${cmd} deleteDataset ${destinationDatasetId}`, cwd); + // eslint-disable-next-line no-empty } catch (err) {} // Ignore error }); -test.serial(`should create a dataset`, async t => { +it('should create a dataset', async () => { const output = await tools.runAsync(`${cmd} createDataset ${datasetId}`, cwd); - t.is(output, `Created dataset: ${datasetId}`); + assert.strictEqual(output, `Created dataset: ${datasetId}`); }); -test.serial(`should get a dataset`, async t => { +it('should get a dataset', async () => { const output = await tools.runAsync(`${cmd} getDataset ${datasetId}`, cwd); - t.regex(output, /name/); - t.regex(output, /timeZone/); + assert.strictEqual(new RegExp(/name/).test(output), true); + assert.strictEqual(new RegExp(/timeZone/).test(output), true); }); -test.serial(`should patch a dataset`, async t => { +it('should patch a dataset', async () => { const patchTimeZone = 'GMT'; const output = await tools.runAsync( `${cmd} patchDataset ${datasetId} ${patchTimeZone}`, cwd ); - t.is(output, `Dataset ${datasetId} patched with time zone ${patchTimeZone}`); + assert.strictEqual( + output, + `Dataset ${datasetId} patched with time zone ${patchTimeZone}` + ); }); -test.serial(`should list datasets`, async t => { +it('should list datasets', async () => { const output = await tools.runAsync(`${cmd} listDatasets`, cwd); - t.regex(output, /datasets/); + assert.strictEqual(new RegExp(/datasets/).test(output), true); }); -test.serial( - `should de-identify data in a dataset and write to a new dataset`, - async t => { - const output = await tools.runAsync( - `${cmd} deidentifyDataset ${datasetId} ${destinationDatasetId} ${keeplistTags}`, - cwd - ); - t.is( - output, - `De-identified data written from dataset +it('should de-identify data in a dataset and write to a new dataset', async () => { + const output = await tools.runAsync( + `${cmd} deidentifyDataset ${datasetId} ${destinationDatasetId} ${keeplistTags}`, + cwd + ); + assert.strictEqual( + output, + `De-identified data written from dataset ${datasetId} to dataset ${destinationDatasetId}` - ); - } -); + ); +}); -test.serial(`should delete a dataset`, async t => { +it('should delete a dataset', async () => { const output = await tools.runAsync(`${cmd} deleteDataset ${datasetId}`, cwd); - t.is(output, `Deleted dataset: ${datasetId}`); + assert.strictEqual(output, `Deleted dataset: ${datasetId}`); }); diff --git a/healthcare/dicom/package.json b/healthcare/dicom/package.json index 3d14f46954..c5d4d1d351 100644 --- a/healthcare/dicom/package.json +++ b/healthcare/dicom/package.json @@ -9,11 +9,11 @@ "node": ">=6.0.0" }, "scripts": { - "test": "ava -T 1m --verbose system-test/*.test.js" + "test": "mocha system-test/*.test.js --timeout=60000" }, "devDependencies": { "@google-cloud/nodejs-repo-tools": "^3.0.0", - "ava": "^0.25.0" + "mocha": "^5.2.0" }, "dependencies": { "googleapis": "^37.0.0", diff --git a/healthcare/dicom/system-test/dicom_stores.test.js b/healthcare/dicom/system-test/dicom_stores.test.js index c33f459b66..d77808d256 100644 --- a/healthcare/dicom/system-test/dicom_stores.test.js +++ b/healthcare/dicom/system-test/dicom_stores.test.js @@ -15,15 +15,15 @@ 'use strict'; -const path = require(`path`); -const test = require(`ava`); -const tools = require(`@google-cloud/nodejs-repo-tools`); -const uuid = require(`uuid`); +const path = require('path'); +const assert = require('assert'); +const tools = require('@google-cloud/nodejs-repo-tools'); +const uuid = require('uuid'); -const cmdDataset = `node datasets.js`; -const cmd = `node dicom_stores.js`; -const cwdDatasets = path.join(__dirname, `../../datasets`); -const cwd = path.join(__dirname, `..`); +const cmdDataset = 'node datasets.js'; +const cmd = 'node dicom_stores.js'; +const cwdDatasets = path.join(__dirname, '../../datasets'); +const cwd = path.join(__dirname, '..'); const datasetId = `nodejs-docs-samples-test-${uuid.v4()}`.replace(/-/gi, '_'); const dicomStoreId = `nodejs-docs-samples-test-dicom-store${uuid.v4()}`.replace( /-/gi, @@ -35,19 +35,15 @@ const pubsubTopic = `nodejs-docs-samples-test-pubsub${uuid.v4()}`.replace( ); const bucketName = process.env.GCLOUD_STORAGE_BUCKET; + const dcmFileName = `IM-0002-0001-JPEG-BASELINE.dcm`; const gcsUri = bucketName + '/' + dcmFileName; -test.before(tools.checkCredentials); -test.before(async () => { - return tools - .runAsync(`${cmdDataset} createDataset ${datasetId}`, cwdDatasets) - .then(results => { - console.log(results); - return results; - }); +before(async () => { + tools.checkCredentials(); + await tools.runAsync(`${cmdDataset} createDataset ${datasetId}`, cwdDatasets); }); -test.after.always(async () => { +after(async () => { try { await tools.runAsync( `${cmdDataset} deleteDataset ${datasetId}`, @@ -56,58 +52,67 @@ test.after.always(async () => { } catch (err) {} // Ignore error }); -test.serial(`should create a DICOM store`, async t => { +it('should create a DICOM store', async () => { const output = await tools.runAsync( `${cmd} createDicomStore ${datasetId} ${dicomStoreId}`, cwd ); - t.regex(output, /Created DICOM store/); + assert.strictEqual(new RegExp(/Created DICOM store/).test(output), true); }); -test.serial(`should get a DICOM store`, async t => { +it('should get a DICOM store', async () => { const output = await tools.runAsync( `${cmd} getDicomStore ${datasetId} ${dicomStoreId}`, cwd ); - t.regex(output, /Got DICOM store/); + assert.strictEqual(new RegExp(/Got DICOM store/).test(output), true); }); -test.serial(`should patch a DICOM store`, async t => { +it('should patch a DICOM store', async () => { const output = await tools.runAsync( `${cmd} patchDicomStore ${datasetId} ${dicomStoreId} ${pubsubTopic}`, cwd ); - t.regex(output, /Patched DICOM store with Cloud Pub\/Sub topic/); + assert.strictEqual( + new RegExp(/Patched DICOM store with Cloud Pub\/Sub topic/).test(output), + true + ); }); -test.serial(`should list DICOM stores`, async t => { +it('should list DICOM stores', async () => { const output = await tools.runAsync( `${cmd} listDicomStores ${datasetId}`, cwd ); - t.regex(output, /DICOM stores/); + assert.strictEqual(new RegExp(/DICOM stores/).test(output), true); }); -test.serial(`should export a DICOM instance`, async t => { +it('should export a DICOM instance', async () => { const output = await tools.runAsync( `${cmd} exportDicomInstanceGcs ${datasetId} ${dicomStoreId} ${bucketName}`, cwd ); - t.regex(output, /Exported DICOM instances to bucket/); + assert.strictEqual( + new RegExp(/Exported DICOM instances to bucket/).test(output), + true + ); }); -test.serial(`should import a DICOM object from GCS`, async t => { +it('should import a DICOM object from GCS', async () => { const output = await tools.runAsync( `${cmd} importDicomObject ${datasetId} ${dicomStoreId} ${gcsUri}`, cwd ); - t.regex(output, /Imported DICOM objects from bucket/); + assert.strictEqual( + new RegExp(/Imported DICOM objects from bucket/).test(output), + true + ); }); -test(`should delete a DICOM store`, async t => { +it('should delete a DICOM store', async () => { const output = await tools.runAsync( `${cmd} deleteDicomStore ${datasetId} ${dicomStoreId}`, cwd ); - t.regex(output, /Deleted DICOM store/); + assert.strictEqual(new RegExp(/Deleted DICOM store/).test(output), true); }); diff --git a/healthcare/dicom/system-test/dicomweb.test.js b/healthcare/dicom/system-test/dicomweb.test.js index a12e2528f0..de76a5ebf9 100644 --- a/healthcare/dicom/system-test/dicomweb.test.js +++ b/healthcare/dicom/system-test/dicomweb.test.js @@ -15,38 +15,33 @@ 'use strict'; -const path = require(`path`); -const test = require(`ava`); -const tools = require(`@google-cloud/nodejs-repo-tools`); -const uuid = require(`uuid`); +const path = require('path'); +const assert = require('assert'); +const tools = require('@google-cloud/nodejs-repo-tools'); +const uuid = require('uuid'); -const cmdDataset = `node datasets.js`; -const cmdDicomStore = `node dicom_stores.js`; -const cmd = `node dicomweb.js`; -const cwdDatasets = path.join(__dirname, `../../datasets`); -const cwd = path.join(__dirname, `..`); +const cmdDataset = 'node datasets.js'; +const cmdDicomStore = 'node dicom_stores.js'; +const cmd = 'node dicomweb.js'; +const cwdDatasets = path.join(__dirname, '../../datasets'); +const cwd = path.join(__dirname, '..'); const datasetId = `nodejs-docs-samples-test-${uuid.v4()}`.replace(/-/gi, '_'); const dicomStoreId = `nodejs-docs-samples-test-dicom-store${uuid.v4()}`.replace( /-/gi, '_' ); -const dcmFile = `resources/IM-0002-0001-JPEG-BASELINE-edited.dcm`; -const boundary = `DICOMwebBoundary`; +const dcmFile = 'resources/IM-0002-0001-JPEG-BASELINE-edited.dcm'; +const boundary = 'DICOMwebBoundary'; // The studyUid is not assigned by the server and is part of the metadata // of dcmFile. -const studyUid = `1.2.840.113619.2.176.3596.3364818.7819.1259708454.105`; +const studyUid = '1.2.840.113619.2.176.3596.3364818.7819.1259708454.105'; -test.before(tools.checkCredentials); -test.before(async () => { - return tools - .runAsync(`${cmdDataset} createDataset ${datasetId}`, cwdDatasets) - .then(results => { - console.log(results); - return results; - }); +before(async () => { + tools.checkCredentials(); + await tools.runAsync(`${cmdDataset} createDataset ${datasetId}`, cwdDatasets); }); -test.after.always(async () => { +after(async () => { try { await tools.runAsync( `${cmdDataset} deleteDataset ${datasetId}`, @@ -55,7 +50,7 @@ test.after.always(async () => { } catch (err) {} // Ignore error }); -test.serial(`should store a DICOM instance`, async t => { +it('should store a DICOM instance', async () => { await tools.runAsync( `${cmdDicomStore} createDicomStore ${datasetId} ${dicomStoreId}`, cwd @@ -64,31 +59,31 @@ test.serial(`should store a DICOM instance`, async t => { `${cmd} dicomWebStoreInstance ${datasetId} ${dicomStoreId} ${dcmFile} ${boundary}`, cwd ); - t.regex(output, /Stored instance/); + assert.strictEqual(new RegExp(/Stored instance/).test(output), true); }); -test.serial(`should search DICOM instances`, async t => { +it('should search DICOM instances', async () => { const output = await tools.runAsync( `${cmd} dicomWebSearchInstances ${datasetId} ${dicomStoreId}`, cwd ); - t.regex(output, /Instances/); + assert.strictEqual(new RegExp(/Instances/).test(output), true); }); -test.serial(`should retrieve a DICOM study`, async t => { +it('should retrieve a DICOM study', async () => { const output = await tools.runAsync( `${cmd} dicomWebRetrieveStudy ${datasetId} ${dicomStoreId} ${studyUid}`, cwd ); - t.regex(output, /Retrieved study/); + assert.strictEqual(new RegExp(/Retrieved study/).test(output), true); }); -test.serial(`should delete a DICOM study`, async t => { +it('should delete a DICOM study', async () => { const output = await tools.runAsync( `${cmd} dicomWebDeleteStudy ${datasetId} ${dicomStoreId} ${studyUid}`, cwd ); - t.regex(output, /Deleted study/); + assert.strictEqual(new RegExp(/Deleted study/).test(output), true); // Clean up await tools.runAsync( diff --git a/healthcare/fhir/package.json b/healthcare/fhir/package.json index 3d14f46954..c5d4d1d351 100644 --- a/healthcare/fhir/package.json +++ b/healthcare/fhir/package.json @@ -9,11 +9,11 @@ "node": ">=6.0.0" }, "scripts": { - "test": "ava -T 1m --verbose system-test/*.test.js" + "test": "mocha system-test/*.test.js --timeout=60000" }, "devDependencies": { "@google-cloud/nodejs-repo-tools": "^3.0.0", - "ava": "^0.25.0" + "mocha": "^5.2.0" }, "dependencies": { "googleapis": "^37.0.0", diff --git a/healthcare/fhir/system-test/fhir_resources.test.js b/healthcare/fhir/system-test/fhir_resources.test.js index 216ed48699..5808fb6a25 100644 --- a/healthcare/fhir/system-test/fhir_resources.test.js +++ b/healthcare/fhir/system-test/fhir_resources.test.js @@ -15,16 +15,16 @@ 'use strict'; -const path = require(`path`); -const test = require(`ava`); -const tools = require(`@google-cloud/nodejs-repo-tools`); -const uuid = require(`uuid`); +const path = require('path'); +const assert = require('assert'); +const tools = require('@google-cloud/nodejs-repo-tools'); +const uuid = require('uuid'); -const cmdDataset = `node datasets.js`; -const cmdFhirStores = `node fhir_stores.js`; +const cmdDataset = 'node datasets.js'; +const cmdFhirStores = 'node fhir_stores.js'; const cmd = 'node fhir_resources.js'; const cwd = path.join(__dirname, '..'); -const cwdDatasets = path.join(__dirname, `../../datasets`); +const cwdDatasets = path.join(__dirname, '../../datasets'); const datasetId = `nodejs-docs-samples-test-${uuid.v4()}`.replace(/-/gi, '_'); const fhirStoreId = `nodejs-docs-samples-test-fhir-store${uuid.v4()}`.replace( /-/gi, @@ -33,16 +33,11 @@ const fhirStoreId = `nodejs-docs-samples-test-fhir-store${uuid.v4()}`.replace( const resourceType = 'Patient'; let resourceId; -test.before(tools.checkCredentials); -test.before(async () => { - return tools - .runAsync(`${cmdDataset} createDataset ${datasetId}`, cwdDatasets) - .then(results => { - console.log(results); - return results; - }); +before(async () => { + tools.checkCredentials(); + await tools.runAsync(`${cmdDataset} createDataset ${datasetId}`, cwdDatasets); }); -test.after.always(async () => { +after(async () => { try { await tools.runAsync( `${cmdDataset} deleteDataset ${datasetId}`, @@ -51,7 +46,7 @@ test.after.always(async () => { } catch (err) {} // Ignore error }); -test.serial(`should create a FHIR resource`, async t => { +it('should create a FHIR resource', async () => { await tools.runAsync( `${cmdFhirStores} createFhirStore ${datasetId} ${fhirStoreId}`, cwd @@ -63,40 +58,43 @@ test.serial(`should create a FHIR resource`, async t => { const createdMessage = new RegExp( `Created resource ${resourceType} with ID (.*).` ); - t.regex(output, createdMessage); + assert.strictEqual(createdMessage.test(output), true); resourceId = createdMessage.exec(output)[1]; }); -test.serial(`should get a FHIR resource`, async t => { +it('should get a FHIR resource', async () => { const output = await tools.runAsync( `${cmd} getResource ${datasetId} ${fhirStoreId} ${resourceType} ${resourceId}`, cwd ); - t.regex(output, new RegExp(`Got ${resourceType} resource`)); + assert.strictEqual( + new RegExp(`Got ${resourceType} resource`).test(output), + true + ); }); -test.serial(`should update a FHIR resource`, async t => { +it('should update a FHIR resource', async () => { const output = await tools.runAsync( `${cmd} updateResource ${datasetId} ${fhirStoreId} ${resourceType} ${resourceId}`, cwd ); - t.is(output, `Updated ${resourceType} with ID ${resourceId}`); + assert.strictEqual(output, `Updated ${resourceType} with ID ${resourceId}`); }); -test.serial(`should patch a FHIR resource`, async t => { +it('should patch a FHIR resource', async () => { const output = await tools.runAsync( `${cmd} patchResource ${datasetId} ${fhirStoreId} ${resourceType} ${resourceId}`, cwd ); - t.is(output, `Patched ${resourceType} with ID ${resourceId}`); + assert.strictEqual(output, `Patched ${resourceType} with ID ${resourceId}`); }); -test.serial(`should delete a FHIR resource`, async t => { +it('should delete a FHIR resource', async () => { const output = await tools.runAsync( `${cmd} deleteResource ${datasetId} ${fhirStoreId} ${resourceType} ${resourceId}`, cwd ); - t.is(output, `Deleted ${resourceType} with ID ${resourceId}.`); + assert.strictEqual(output, `Deleted ${resourceType} with ID ${resourceId}.`); // Clean up await tools.runAsync( diff --git a/healthcare/fhir/system-test/fhir_stores.test.js b/healthcare/fhir/system-test/fhir_stores.test.js index 54f00b0cc6..dc63ce3aca 100644 --- a/healthcare/fhir/system-test/fhir_stores.test.js +++ b/healthcare/fhir/system-test/fhir_stores.test.js @@ -15,15 +15,15 @@ 'use strict'; -const path = require(`path`); -const test = require(`ava`); -const tools = require(`@google-cloud/nodejs-repo-tools`); -const uuid = require(`uuid`); +const path = require('path'); +const assert = require('assert'); +const tools = require('@google-cloud/nodejs-repo-tools'); +const uuid = require('uuid'); -const cmdDataset = `node datasets.js`; -const cmd = `node fhir_stores.js`; -const cwdDatasets = path.join(__dirname, `../../datasets`); -const cwd = path.join(__dirname, `..`); +const cmdDataset = 'node datasets.js'; +const cmd = 'node fhir_stores.js'; +const cwdDatasets = path.join(__dirname, '../../datasets'); +const cwd = path.join(__dirname, '..'); const datasetId = `nodejs-docs-samples-test-${uuid.v4()}`.replace(/-/gi, '_'); const fhirStoreId = `nodejs-docs-samples-test-fhir-store${uuid.v4()}`.replace( /-/gi, @@ -34,16 +34,11 @@ const pubsubTopic = `nodejs-docs-samples-test-pubsub${uuid.v4()}`.replace( '_' ); -test.before(tools.checkCredentials); -test.before(async () => { - return tools - .runAsync(`${cmdDataset} createDataset ${datasetId}`, cwdDatasets) - .then(results => { - console.log(results); - return results; - }); +before(async () => { + tools.checkCredentials(); + await tools.runAsync(`${cmdDataset} createDataset ${datasetId}`, cwdDatasets); }); -test.after.always(async () => { +after(async () => { try { await tools.runAsync( `${cmdDataset} deleteDataset ${datasetId}`, @@ -52,50 +47,53 @@ test.after.always(async () => { } catch (err) {} // Ignore error }); -test.serial(`should create a FHIR store`, async t => { +it('should create a FHIR store', async () => { const output = await tools.runAsync( `${cmd} createFhirStore ${datasetId} ${fhirStoreId}`, cwd ); - t.regex(output, /Created FHIR store/); + assert.strictEqual(new RegExp(/Created FHIR store/).test(output), true); }); -test.serial(`should get a FHIR store`, async t => { +it('should get a FHIR store', async () => { const output = await tools.runAsync( `${cmd} getFhirStore ${datasetId} ${fhirStoreId}`, cwd ); - t.regex(output, /Got FHIR store/); + assert.strictEqual(new RegExp(/Got FHIR store/).test(output), true); }); -test.serial(`should list FHIR stores`, async t => { +it('should list FHIR stores', async () => { const output = await tools.runAsync( `${cmd} listFhirStores ${datasetId}`, cwd ); - t.regex(output, /FHIR stores/); + assert.strictEqual(new RegExp(/FHIR stores/).test(output), true); }); -test.serial(`should patch a FHIR store`, async t => { +it('should patch a FHIR store', async () => { const output = await tools.runAsync( `${cmd} patchFhirStore ${datasetId} ${fhirStoreId} ${pubsubTopic}`, cwd ); - t.regex(output, /Patched FHIR store/); + assert.strictEqual(new RegExp(/Patched FHIR store/).test(output), true); }); -test.serial(`should get FHIR store metadata`, async t => { +it('should get FHIR store metadata', async () => { const output = await tools.runAsync( `${cmd} getMetadata ${datasetId} ${fhirStoreId}`, cwd ); - t.regex(output, /Capabilities statement for FHIR store/); + assert.strictEqual( + new RegExp(/Capabilities statement for FHIR store/).test(output), + true + ); }); -test(`should delete a FHIR store`, async t => { +it('should delete a FHIR store', async () => { const output = await tools.runAsync( `${cmd} deleteFhirStore ${datasetId} ${fhirStoreId}`, cwd ); - t.regex(output, /Deleted FHIR store/); + assert.strictEqual(new RegExp(/Deleted FHIR store/).test(output), true); }); diff --git a/healthcare/hl7v2/package.json b/healthcare/hl7v2/package.json index 5c29cb9add..a360df018c 100644 --- a/healthcare/hl7v2/package.json +++ b/healthcare/hl7v2/package.json @@ -9,11 +9,11 @@ "node": ">=6.0.0" }, "scripts": { - "test": "ava -T 1m --verbose system-test/*.test.js" + "test": "mocha system-test/*.test.js --timeout=60000" }, "devDependencies": { "@google-cloud/nodejs-repo-tools": "^3.0.0", - "ava": "^0.25.0" + "mocha": "^5.2.0" }, "dependencies": { "googleapis": "^37.0.0", diff --git a/healthcare/hl7v2/system-test/hl7v2_messages.test.js b/healthcare/hl7v2/system-test/hl7v2_messages.test.js index 901a87aea9..928c23f255 100644 --- a/healthcare/hl7v2/system-test/hl7v2_messages.test.js +++ b/healthcare/hl7v2/system-test/hl7v2_messages.test.js @@ -15,37 +15,32 @@ 'use strict'; -const path = require(`path`); -const test = require(`ava`); -const tools = require(`@google-cloud/nodejs-repo-tools`); -const uuid = require(`uuid`); +const path = require('path'); +const assert = require('assert'); +const tools = require('@google-cloud/nodejs-repo-tools'); +const uuid = require('uuid'); -const cmdDataset = `node datasets.js`; -const cmd = `node hl7v2_messages.js`; -const cmdHl7v2Store = `node hl7v2_stores.js`; -const cwdDatasets = path.join(__dirname, `../../datasets`); -const cwd = path.join(__dirname, `..`); +const cmdDataset = 'node datasets.js'; +const cmd = 'node hl7v2_messages.js'; +const cmdHl7v2Store = 'node hl7v2_stores.js'; +const cwdDatasets = path.join(__dirname, '../../datasets'); +const cwd = path.join(__dirname, '..'); const datasetId = `nodejs-docs-samples-test-${uuid.v4()}`.replace(/-/gi, '_'); const hl7v2StoreId = `nodejs-docs-samples-test-hl7v2-store${uuid.v4()}`.replace( /-/gi, '_' ); -const messageFile = `resources/hl7v2-sample-ingest.json`; -const messageId = `2yqbdhYHlk_ucSmWkcKOVm_N0p0OpBXgIlVG18rB-cw=`; -const labelKey = `my-key`; -const labelValue = `my-value`; +const messageFile = 'resources/hl7v2-sample-ingest.json'; +const messageId = '2yqbdhYHlk_ucSmWkcKOVm_N0p0OpBXgIlVG18rB-cw='; +const labelKey = 'my-key'; +const labelValue = 'my-value'; -test.before(tools.checkCredentials); -test.before(async () => { - return tools - .runAsync(`${cmdDataset} createDataset ${datasetId}`, cwdDatasets) - .then(results => { - console.log(results); - return results; - }); +before(async () => { + tools.checkCredentials(); + await tools.runAsync(`${cmdDataset} createDataset ${datasetId}`, cwdDatasets); }); -test.after.always(async () => { +after(async () => { try { await tools.runAsync( `${cmdDataset} deleteDataset ${datasetId}`, @@ -54,7 +49,7 @@ test.after.always(async () => { } catch (err) {} // Ignore error }); -test.serial(`should create an HL7v2 message`, async t => { +it('should create an HL7v2 message', async () => { await tools.runAsync( `${cmdHl7v2Store} createHl7v2Store ${datasetId} ${hl7v2StoreId}`, cwd @@ -63,47 +58,47 @@ test.serial(`should create an HL7v2 message`, async t => { `${cmd} createHl7v2Message ${datasetId} ${hl7v2StoreId} ${messageFile}`, cwd ); - t.regex(output, /Created HL7v2 message/); + assert.strictEqual(new RegExp(/Created HL7v2 message/).test(output), true); }); -test.serial(`should ingest an HL7v2 message`, async t => { +it('should ingest an HL7v2 message', async () => { const output = await tools.runAsync( `${cmd} ingestHl7v2Message ${datasetId} ${hl7v2StoreId} ${messageFile}`, cwd ); - t.regex(output, /Ingested HL7v2 message/); + assert.strictEqual(new RegExp(/Ingested HL7v2 message/).test(output), true); }); -test.serial(`should get an HL7v2 message`, async t => { +it('should get an HL7v2 message', async () => { const output = await tools.runAsync( `${cmd} getHl7v2Message ${datasetId} ${hl7v2StoreId} ${messageId}`, cwd ); - t.regex(output, /Got HL7v2 message/); + assert.strictEqual(new RegExp(/Got HL7v2 message/).test(output), true); }); -test.serial(`should list HL7v2 messages`, async t => { +it('should list HL7v2 messages', async () => { const output = await tools.runAsync( `${cmd} listHl7v2Messages ${datasetId} ${hl7v2StoreId}`, cwd ); - t.regex(output, /HL7v2 messages/); + assert.strictEqual(new RegExp(/HL7v2 messages/).test(output), true); }); -test.serial(`should patch an HL7v2 message`, async t => { +it('should patch an HL7v2 message', async () => { const output = await tools.runAsync( `${cmd} patchHl7v2Message ${datasetId} ${hl7v2StoreId} ${messageId} ${labelKey} ${labelValue}`, cwd ); - t.regex(output, /Patched HL7v2 message/); + assert.strictEqual(new RegExp(/Patched HL7v2 message/).test(output), true); }); -test(`should delete an HL7v2 message`, async t => { +it('should delete an HL7v2 message', async () => { const output = await tools.runAsync( `${cmd} deleteHl7v2Message ${datasetId} ${hl7v2StoreId} ${messageId}`, cwd ); - t.regex(output, /Deleted HL7v2 message/); + assert.strictEqual(new RegExp(/Deleted HL7v2 message/).test(output), true); // Clean up tools.runAsync( diff --git a/healthcare/hl7v2/system-test/hl7v2_stores.test.js b/healthcare/hl7v2/system-test/hl7v2_stores.test.js index 9aef63ca27..bacfc0fe5a 100644 --- a/healthcare/hl7v2/system-test/hl7v2_stores.test.js +++ b/healthcare/hl7v2/system-test/hl7v2_stores.test.js @@ -15,15 +15,15 @@ 'use strict'; -const path = require(`path`); -const test = require(`ava`); -const tools = require(`@google-cloud/nodejs-repo-tools`); -const uuid = require(`uuid`); +const path = require('path'); +const assert = require('assert'); +const tools = require('@google-cloud/nodejs-repo-tools'); +const uuid = require('uuid'); -const cmdDataset = `node datasets.js`; -const cmd = `node hl7v2_stores.js`; -const cwdDatasets = path.join(__dirname, `../../datasets`); -const cwd = path.join(__dirname, `..`); +const cmdDataset = 'node datasets.js'; +const cmd = 'node hl7v2_stores.js'; +const cwdDatasets = path.join(__dirname, '../../datasets'); +const cwd = path.join(__dirname, '..'); const datasetId = `nodejs-docs-samples-test-${uuid.v4()}`.replace(/-/gi, '_'); const hl7v2StoreId = `nodejs-docs-samples-test-hl7v2-store${uuid.v4()}`.replace( /-/gi, @@ -34,16 +34,11 @@ const pubsubTopic = `nodejs-docs-samples-test-pubsub${uuid.v4()}`.replace( '_' ); -test.before(tools.checkCredentials); -test.before(async () => { - return tools - .runAsync(`${cmdDataset} createDataset ${datasetId}`, cwdDatasets) - .then(results => { - console.log(results); - return results; - }); +before(async () => { + tools.checkCredentials(); + await tools.runAsync(`${cmdDataset} createDataset ${datasetId}`, cwdDatasets); }); -test.after.always(async () => { +after(async () => { try { await tools.runAsync( `${cmdDataset} deleteDataset ${datasetId}`, @@ -52,42 +47,45 @@ test.after.always(async () => { } catch (err) {} // Ignore error }); -test.serial(`should create an HL7v2 store`, async t => { +it('should create an HL7v2 store', async () => { const output = await tools.runAsync( `${cmd} createHl7v2Store ${datasetId} ${hl7v2StoreId}`, cwd ); - t.regex(output, /Created HL7v2 store/); + assert.strictEqual(new RegExp(/Created HL7v2 store/).test(output), true); }); -test.serial(`should get an HL7v2 store`, async t => { +it('should get an HL7v2 store', async () => { const output = await tools.runAsync( `${cmd} getHl7v2Store ${datasetId} ${hl7v2StoreId}`, cwd ); - t.regex(output, /Got HL7v2 store/); + assert.strictEqual(new RegExp(/Got HL7v2 store/).test(output), true); }); -test.serial(`should patch an HL7v2 store`, async t => { +it('should patch an HL7v2 store', async () => { const output = await tools.runAsync( `${cmd} patchHl7v2Store ${datasetId} ${hl7v2StoreId} ${pubsubTopic}`, cwd ); - t.regex(output, /Patched HL7v2 store with Cloud Pub\/Sub topic/); + assert.strictEqual( + new RegExp(/Patched HL7v2 store with Cloud Pub\/Sub topic/).test(output), + true + ); }); -test.serial(`should list HL7v2 stores`, async t => { +it('should list HL7v2 stores', async () => { const output = await tools.runAsync( `${cmd} listHl7v2Stores ${datasetId}`, cwd ); - t.regex(output, /HL7v2 stores/); + assert.strictEqual(new RegExp(/HL7v2 stores/).test(output), true); }); -test(`should delete an HL7v2 Store`, async t => { +it('should delete an HL7v2 Store', async () => { const output = await tools.runAsync( `${cmd} deleteHl7v2Store ${datasetId} ${hl7v2StoreId}`, cwd ); - t.regex(output, /Deleted HL7v2 store/); + assert.strictEqual(new RegExp(/Deleted HL7v2 store/).test(output), true); });