test(contrib/drivers/gaussdb): add transaction, where, hook, ctx test coverage - #4685
Conversation
… coverage Port 4 test files from PgSQL driver to GaussDB driver to align test coverage: - gaussdb_z_unit_transaction_test.go (40 tests) - gaussdb_z_unit_model_where_test.go (35 tests) - gaussdb_z_unit_feature_hook_test.go (6 tests) - gaussdb_z_unit_feature_ctx_test.go (5 tests) Remove old Test_Model_Where from gaussdb_z_unit_model_test.go, replaced by comprehensive version in dedicated where test file.
There was a problem hiding this comment.
Pull request overview
This PR expands the GaussDB driver test suite by porting and extending unit/feature tests (transactions, WHERE clause handling, hooks, and context propagation) to better align coverage with other SQL drivers.
Changes:
- Added extensive transaction tests covering nested transactions, savepoints, propagation modes, panic recovery, and isolation levels.
- Added a dedicated and comprehensive
Model.Where/WherePri/...test file, replacing a smallerTest_Model_Wherein the existing model test file. - Added feature tests for model hooks and context propagation behaviors.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| contrib/drivers/gaussdb/gaussdb_z_unit_transaction_test.go | Adds broad transaction behavior coverage (nested TX, savepoints, propagation, isolation). |
| contrib/drivers/gaussdb/gaussdb_z_unit_model_where_test.go | Adds comprehensive WHERE/WHEREPRI coverage across many input forms and operators. |
| contrib/drivers/gaussdb/gaussdb_z_unit_model_test.go | Removes the older minimal Test_Model_Where now covered by the new dedicated file. |
| contrib/drivers/gaussdb/gaussdb_z_unit_feature_hook_test.go | Adds hook handler tests for Select/Insert/Update/Delete behaviors. |
| contrib/drivers/gaussdb/gaussdb_z_unit_feature_ctx_test.go | Adds tests around context propagation, logging keys, transactions, and timeouts. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
@gqcn 感谢review,这里解释一下几个设计选择: 关于事务测试忽略Insert错误: 关于Hook测试用db.Model: 关于Ctx测试忽略返回值: 这些模式都是为了跟MySQL基线对齐,方便后续横向比对各驱动的测试覆盖率。👍 |
Summary
gaussdb_z_unit_transaction_test.go(40 tests): nested transactions, savepoints, rollback, panic recovery, context propagationgaussdb_z_unit_model_where_test.go(35 tests): comprehensive Where clause combinations (map, slice, struct, pointer, operators, nil, empty)gaussdb_z_unit_feature_hook_test.go(6 tests): model hook callbacks (Select/Insert/Update/Delete)gaussdb_z_unit_feature_ctx_test.go(5 tests): context propagation, timeout, logging with contextTest_Model_Where(2 sub-tests) fromgaussdb_z_unit_model_test.go, replaced by comprehensive version in dedicated where test file (35 tests)Test plan
go build ./...passesgofmtandgciappliedpgsqlreferences in new filesgo test -v -run "Test_TX_" -count=1against GaussDB instancego test -v -run "Test_Model_Where" -count=1against GaussDB instancego test -v -run "Test_Model_Hook" -count=1against GaussDB instancego test -v -run "Test_Ctx" -count=1against GaussDB instanceref #4689