Skip to content

Commit

Permalink
samples: rename the file with prefix and added unhandled promise reje…
Browse files Browse the repository at this point in the history
…ction
  • Loading branch information
Lalji Kanjareeya committed Apr 22, 2021
1 parent 8ebaea1 commit 2aa53d9
Show file tree
Hide file tree
Showing 14 changed files with 65 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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));
4 changes: 4 additions & 0 deletions samples/delete-using-dml.js → samples/dml-delete.js
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Original file line number Diff line number Diff line change
Expand Up @@ -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));
4 changes: 4 additions & 0 deletions samples/insert-using-dml.js → samples/dml-insert.js
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Original file line number Diff line number Diff line change
Expand Up @@ -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));
4 changes: 4 additions & 0 deletions samples/update-using-dml.js → samples/dml-update.js
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Original file line number Diff line number Diff line change
Expand Up @@ -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));
4 changes: 4 additions & 0 deletions samples/write-using-dml.js → samples/dml-write.js
Original file line number Diff line number Diff line change
Expand Up @@ -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));
26 changes: 13 additions & 13 deletions samples/system-test/spanner.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -680,63 +680,63 @@ 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/);
});

// 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\./);
});

// 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/);
});

// 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/);
});

// 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/);
});

// 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/);
});

// 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/);
});

// 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,
Expand All @@ -747,23 +747,23 @@ 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/);
});

// 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/);
});

// 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,
Expand Down Expand Up @@ -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./);
});
Expand Down

0 comments on commit 2aa53d9

Please sign in to comment.