From 2aa53d96c97dbfb3e025f1597238130f435881a0 Mon Sep 17 00:00:00 2001 From: Lalji Kanjareeya Date: Thu, 22 Apr 2021 20:12:55 +0530 Subject: [PATCH] samples: rename the file with prefix and added unhandled promise rejection --- ...dml.js => dml-delete-using-partitioned.js} | 4 +++ .../{delete-using-dml.js => dml-delete.js} | 4 +++ ...with-custom-timeout-and-retry-settings.js} | 4 +++ .../{insert-using-dml.js => dml-insert.js} | 4 +++ ...er.js => dml-query-data-with-parameter.js} | 4 +++ ...batch-dml.js => dml-update-using-batch.js} | 4 +++ ...dml.js => dml-update-using-partitioned.js} | 4 +++ ...th-struct.js => dml-update-with-struct.js} | 4 +++ ...estamp.js => dml-update-with-timestamp.js} | 4 +++ .../{update-using-dml.js => dml-update.js} | 4 +++ ...ead-using-dml.js => dml-write-and-read.js} | 4 +++ ...g-dml.js => dml-write-with-transaction.js} | 4 +++ samples/{write-using-dml.js => dml-write.js} | 4 +++ samples/system-test/spanner.test.js | 26 +++++++++---------- 14 files changed, 65 insertions(+), 13 deletions(-) rename samples/{delete-using-partitioned-dml.js => dml-delete-using-partitioned.js} (95%) rename samples/{delete-using-dml.js => dml-delete.js} (95%) rename samples/{insert-with-custom-timeout-and-retry-settings.js => dml-insert-with-custom-timeout-and-retry-settings.js} (96%) rename samples/{insert-using-dml.js => dml-insert.js} (95%) rename samples/{query-data-with-parameter.js => dml-query-data-with-parameter.js} (95%) rename samples/{update-using-batch-dml.js => dml-update-using-batch.js} (96%) rename samples/{update-using-partitioned-dml.js => dml-update-using-partitioned.js} (95%) rename samples/{update-using-dml-with-struct.js => dml-update-with-struct.js} (96%) rename samples/{update-using-dml-with-timestamp.js => dml-update-with-timestamp.js} (95%) rename samples/{update-using-dml.js => dml-update.js} (95%) rename samples/{write-and-read-using-dml.js => dml-write-and-read.js} (96%) rename samples/{write-with-transaction-using-dml.js => dml-write-with-transaction.js} (97%) rename samples/{write-using-dml.js => dml-write.js} (95%) diff --git a/samples/delete-using-partitioned-dml.js b/samples/dml-delete-using-partitioned.js similarity index 95% rename from samples/delete-using-partitioned-dml.js rename to samples/dml-delete-using-partitioned.js index b946288e2..68b0c9100 100644 --- a/samples/delete-using-partitioned-dml.js +++ b/samples/dml-delete-using-partitioned.js @@ -59,4 +59,8 @@ function main( deleteUsingPartitionedDml().catch(console.error); // [END spanner_dml_partitioned_delete] } +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); main(...process.argv.slice(2)); diff --git a/samples/delete-using-dml.js b/samples/dml-delete.js similarity index 95% rename from samples/delete-using-dml.js rename to samples/dml-delete.js index 35f08e0d6..91f446bb2 100644 --- a/samples/delete-using-dml.js +++ b/samples/dml-delete.js @@ -67,4 +67,8 @@ function main( deleteUsingDml().catch(console.error); // [END spanner_dml_standard_delete] } +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); main(...process.argv.slice(2)); diff --git a/samples/insert-with-custom-timeout-and-retry-settings.js b/samples/dml-insert-with-custom-timeout-and-retry-settings.js similarity index 96% rename from samples/insert-with-custom-timeout-and-retry-settings.js rename to samples/dml-insert-with-custom-timeout-and-retry-settings.js index 60fbb3b9a..84a8eec7a 100644 --- a/samples/insert-with-custom-timeout-and-retry-settings.js +++ b/samples/dml-insert-with-custom-timeout-and-retry-settings.js @@ -77,4 +77,8 @@ function main( insertWithCustomTimeoutAndRetrySettings().catch(console.error); // [END spanner_set_custom_timeout_and_retry] } +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); main(...process.argv.slice(2)); diff --git a/samples/insert-using-dml.js b/samples/dml-insert.js similarity index 95% rename from samples/insert-using-dml.js rename to samples/dml-insert.js index 03fe953d9..b9b84ad85 100644 --- a/samples/insert-using-dml.js +++ b/samples/dml-insert.js @@ -75,4 +75,8 @@ function main( insertUsingDml().catch(console.error); // [END spanner_dml_standard_insert] } +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); main(...process.argv.slice(2)); diff --git a/samples/query-data-with-parameter.js b/samples/dml-query-data-with-parameter.js similarity index 95% rename from samples/query-data-with-parameter.js rename to samples/dml-query-data-with-parameter.js index f64c07af9..849fed98b 100644 --- a/samples/query-data-with-parameter.js +++ b/samples/dml-query-data-with-parameter.js @@ -72,4 +72,8 @@ function main( queryDataWithParameter().catch(console.error); // [END spanner_query_with_parameter] } +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); main(...process.argv.slice(2)); diff --git a/samples/update-using-batch-dml.js b/samples/dml-update-using-batch.js similarity index 96% rename from samples/update-using-batch-dml.js rename to samples/dml-update-using-batch.js index f19fe3a2c..1ce8da5d5 100644 --- a/samples/update-using-batch-dml.js +++ b/samples/dml-update-using-batch.js @@ -75,4 +75,8 @@ function main( updateUsingBatchDml().catch(console.error); // [END spanner_dml_batch_update] } +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); main(...process.argv.slice(2)); diff --git a/samples/update-using-partitioned-dml.js b/samples/dml-update-using-partitioned.js similarity index 95% rename from samples/update-using-partitioned-dml.js rename to samples/dml-update-using-partitioned.js index e66866d32..3ea9f372a 100644 --- a/samples/update-using-partitioned-dml.js +++ b/samples/dml-update-using-partitioned.js @@ -59,4 +59,8 @@ function main( updateUsingPartitionedDml().catch(console.error); // [END spanner_dml_partitioned_update] } +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); main(...process.argv.slice(2)); diff --git a/samples/update-using-dml-with-struct.js b/samples/dml-update-with-struct.js similarity index 96% rename from samples/update-using-dml-with-struct.js rename to samples/dml-update-with-struct.js index 5a14a9988..a23da2fda 100644 --- a/samples/update-using-dml-with-struct.js +++ b/samples/dml-update-with-struct.js @@ -76,4 +76,8 @@ function main( updateUsingDmlWithStruct().catch(console.error); // [END spanner_dml_structs] } +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); main(...process.argv.slice(2)); diff --git a/samples/update-using-dml-with-timestamp.js b/samples/dml-update-with-timestamp.js similarity index 95% rename from samples/update-using-dml-with-timestamp.js rename to samples/dml-update-with-timestamp.js index 2edd02909..1836564c3 100644 --- a/samples/update-using-dml-with-timestamp.js +++ b/samples/dml-update-with-timestamp.js @@ -69,4 +69,8 @@ function main( updateUsingDmlWithTimestamp().catch(console.error); // [END spanner_dml_standard_update_with_timestamp] } +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); main(...process.argv.slice(2)); diff --git a/samples/update-using-dml.js b/samples/dml-update.js similarity index 95% rename from samples/update-using-dml.js rename to samples/dml-update.js index 63c2f9f6c..2c4d0fa0d 100644 --- a/samples/update-using-dml.js +++ b/samples/dml-update.js @@ -68,4 +68,8 @@ function main( updateUsingDml().catch(console.error); // [END spanner_dml_standard_update] } +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); main(...process.argv.slice(2)); diff --git a/samples/write-and-read-using-dml.js b/samples/dml-write-and-read.js similarity index 96% rename from samples/write-and-read-using-dml.js rename to samples/dml-write-and-read.js index 9a00b232b..0144c86f6 100644 --- a/samples/write-and-read-using-dml.js +++ b/samples/dml-write-and-read.js @@ -75,4 +75,8 @@ function main( writeAndReadUsingDml().catch(console.error); // [END spanner_dml_write_then_read] } +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); main(...process.argv.slice(2)); diff --git a/samples/write-with-transaction-using-dml.js b/samples/dml-write-with-transaction.js similarity index 97% rename from samples/write-with-transaction-using-dml.js rename to samples/dml-write-with-transaction.js index 7f615c3cf..9f7735c47 100644 --- a/samples/write-with-transaction-using-dml.js +++ b/samples/dml-write-with-transaction.js @@ -136,4 +136,8 @@ function main( writeWithTransactionUsingDml().catch(console.error); // [END spanner_dml_getting_started_update] } +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); main(...process.argv.slice(2)); diff --git a/samples/write-using-dml.js b/samples/dml-write.js similarity index 95% rename from samples/write-using-dml.js rename to samples/dml-write.js index 724a808c2..08d2f0b83 100644 --- a/samples/write-using-dml.js +++ b/samples/dml-write.js @@ -70,4 +70,8 @@ function main( writeUsingDml().catch(console.error); // [END spanner_dml_getting_started_insert] } +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); main(...process.argv.slice(2)); diff --git a/samples/system-test/spanner.test.js b/samples/system-test/spanner.test.js index 25a85eb6a..51b3af77d 100644 --- a/samples/system-test/spanner.test.js +++ b/samples/system-test/spanner.test.js @@ -669,7 +669,7 @@ describe('Spanner', () => { // dml_standard_insert it('should insert rows into an example table using a DML statement', async () => { const output = execSync( - `node insert-using-dml ${INSTANCE_ID} ${DATABASE_ID} ${PROJECT_ID}` + `node dml-insert ${INSTANCE_ID} ${DATABASE_ID} ${PROJECT_ID}` ); assert.match( output, @@ -680,7 +680,7 @@ describe('Spanner', () => { // dml_standard_update it('should update a row in an example table using a DML statement', async () => { const output = execSync( - `node update-using-dml ${INSTANCE_ID} ${DATABASE_ID} ${PROJECT_ID}` + `node dml-update ${INSTANCE_ID} ${DATABASE_ID} ${PROJECT_ID}` ); assert.match(output, /Successfully updated 1 record/); }); @@ -688,7 +688,7 @@ describe('Spanner', () => { // dml_standard_delete it('should delete a row from an example table using a DML statement', async () => { const output = execSync( - `node delete-using-dml ${INSTANCE_ID} ${DATABASE_ID} ${PROJECT_ID}` + `node dml-delete ${INSTANCE_ID} ${DATABASE_ID} ${PROJECT_ID}` ); assert.match(output, /Successfully deleted 1 record\./); }); @@ -696,7 +696,7 @@ describe('Spanner', () => { // dml_standard_update_with_timestamp it('should update the timestamp of multiple records in an example table using a DML statement', async () => { const output = execSync( - `node update-using-dml-with-timestamp ${INSTANCE_ID} ${DATABASE_ID} ${PROJECT_ID}` + `node dml-update-with-timestamp ${INSTANCE_ID} ${DATABASE_ID} ${PROJECT_ID}` ); assert.match(output, /Successfully updated 2 records/); }); @@ -704,7 +704,7 @@ describe('Spanner', () => { // dml_write_then_read it('should insert a record in an example table using a DML statement and then query the record', async () => { const output = execSync( - `node write-and-read-using-dml ${INSTANCE_ID} ${DATABASE_ID} ${PROJECT_ID}` + `node dml-write-and-read ${INSTANCE_ID} ${DATABASE_ID} ${PROJECT_ID}` ); assert.match(output, /Timothy Campbell/); }); @@ -712,7 +712,7 @@ describe('Spanner', () => { // dml_structs it('should update a record in an example table using a DML statement along with a struct value', async () => { const output = execSync( - `node update-using-dml-with-struct ${INSTANCE_ID} ${DATABASE_ID} ${PROJECT_ID}` + `node dml-update-with-struct ${INSTANCE_ID} ${DATABASE_ID} ${PROJECT_ID}` ); assert.match(output, /Successfully updated 1 record/); }); @@ -720,7 +720,7 @@ describe('Spanner', () => { // dml_getting_started_insert it('should insert multiple records into an example table using a DML statement', async () => { const output = execSync( - `node write-using-dml ${INSTANCE_ID} ${DATABASE_ID} ${PROJECT_ID}` + `node dml-write ${INSTANCE_ID} ${DATABASE_ID} ${PROJECT_ID}` ); assert.match(output, /4 records inserted/); }); @@ -728,7 +728,7 @@ describe('Spanner', () => { // dml_query_with_parameter it('should use a parameter query to query record that was inserted using a DML statement', async () => { const output = execSync( - `node query-data-with-parameter ${INSTANCE_ID} ${DATABASE_ID} ${PROJECT_ID}` + `node dml-query-data-with-parameter ${INSTANCE_ID} ${DATABASE_ID} ${PROJECT_ID}` ); assert.match(output, /SingerId: 12, FirstName: Melissa, LastName: Garcia/); }); @@ -736,7 +736,7 @@ describe('Spanner', () => { // dml_getting_started_update it('should transfer value from one record to another using DML statements within a transaction', async () => { const output = execSync( - `node write-with-transaction-using-dml ${INSTANCE_ID} ${DATABASE_ID} ${PROJECT_ID}` + `node dml-write-with-transaction ${INSTANCE_ID} ${DATABASE_ID} ${PROJECT_ID}` ); assert.match( output, @@ -747,7 +747,7 @@ describe('Spanner', () => { // dml_partitioned_update it('should update multiple records using a partitioned DML statement', async () => { const output = execSync( - `node update-using-partitioned-dml ${INSTANCE_ID} ${DATABASE_ID} ${PROJECT_ID}` + `node dml-update-using-partitioned ${INSTANCE_ID} ${DATABASE_ID} ${PROJECT_ID}` ); assert.match(output, /Successfully updated 3 records/); }); @@ -755,7 +755,7 @@ describe('Spanner', () => { // dml_partitioned_delete it('should delete multiple records using a partitioned DML statement', async () => { const output = execSync( - `node delete-using-partitioned-dml ${INSTANCE_ID} ${DATABASE_ID} ${PROJECT_ID}` + `node dml-delete-using-partitioned ${INSTANCE_ID} ${DATABASE_ID} ${PROJECT_ID}` ); assert.match(output, /Successfully deleted 5 records/); }); @@ -763,7 +763,7 @@ describe('Spanner', () => { // dml_batch_update it('should insert and update records using Batch DML', async () => { const output = execSync( - `node update-using-batch-dml ${INSTANCE_ID} ${DATABASE_ID} ${PROJECT_ID}` + `node dml-update-using-batch ${INSTANCE_ID} ${DATABASE_ID} ${PROJECT_ID}` ); assert.match( output, @@ -1073,7 +1073,7 @@ describe('Spanner', () => { // custom_timeout_and_retry it('should insert with custom timeout and retry settings', async () => { const output = execSync( - `node insert-with-custom-timeout-and-retry-settings ${INSTANCE_ID} ${DATABASE_ID} ${PROJECT_ID}` + `node dml-insert-with-custom-timeout-and-retry-settings ${INSTANCE_ID} ${DATABASE_ID} ${PROJECT_ID}` ); assert.match(output, /record inserted./); });