mirror of
https://gitee.com/johng/gf
synced 2026-06-06 02:25:47 +08:00
test(contrib/drivers/pgsql): add SoftTime, With, ScanList test coverage (#4676)
## Summary - Add 3 new test files for pgsql driver (39 test functions, ~3800 lines) - `pgsql_z_unit_feature_soft_time_test.go`: 15 tests — soft delete (SoftDeleted/Unscoped), auto time fields (CreatedAt/UpdatedAt/DeletedAt), time format options - `pgsql_z_unit_feature_with_test.go`: 17 tests — With relation queries (one-to-one, one-to-many, many-to-many), nested With, WithAll, conditional With - `pgsql_z_unit_feature_scanlist_test.go`: 7 tests — ScanList relation mapping for struct slices - Add testdata SQL templates for With tests **PostgreSQL adaptations from MySQL:** - `AUTO_INCREMENT` → `SERIAL/BIGSERIAL` - `datetime` → `timestamp` - MySQL backticks → PostgreSQL double quotes for identifiers - Timestamp format handling for soft time fields ## Test plan - [x] Run `go test -v -run "Test_Model_Soft" -count=1` in `contrib/drivers/pgsql` - [x] Run `go test -v -run "Test_Model_With" -count=1` in `contrib/drivers/pgsql` - [x] Run `go test -v -run "Test_Model_ScanList" -count=1` in `contrib/drivers/pgsql` ref #4689
This commit is contained in:
1004
contrib/drivers/pgsql/pgsql_z_unit_feature_scanlist_test.go
Normal file
1004
contrib/drivers/pgsql/pgsql_z_unit_feature_scanlist_test.go
Normal file
File diff suppressed because it is too large
Load Diff
1301
contrib/drivers/pgsql/pgsql_z_unit_feature_soft_time_test.go
Normal file
1301
contrib/drivers/pgsql/pgsql_z_unit_feature_soft_time_test.go
Normal file
File diff suppressed because it is too large
Load Diff
1592
contrib/drivers/pgsql/pgsql_z_unit_feature_with_test.go
Normal file
1592
contrib/drivers/pgsql/pgsql_z_unit_feature_with_test.go
Normal file
File diff suppressed because it is too large
Load Diff
30
contrib/drivers/pgsql/testdata/with_multiple_depends.sql
vendored
Normal file
30
contrib/drivers/pgsql/testdata/with_multiple_depends.sql
vendored
Normal file
@ -0,0 +1,30 @@
|
||||
|
||||
CREATE TABLE table_a (
|
||||
id SERIAL PRIMARY KEY,
|
||||
alias varchar(255) DEFAULT ''
|
||||
);
|
||||
|
||||
INSERT INTO table_a VALUES (1, 'table_a_test1');
|
||||
INSERT INTO table_a VALUES (2, 'table_a_test2');
|
||||
|
||||
CREATE TABLE table_b (
|
||||
id SERIAL PRIMARY KEY,
|
||||
table_a_id integer NOT NULL,
|
||||
alias varchar(255) DEFAULT ''
|
||||
);
|
||||
|
||||
INSERT INTO table_b VALUES (10, 1, 'table_b_test1');
|
||||
INSERT INTO table_b VALUES (20, 2, 'table_b_test2');
|
||||
INSERT INTO table_b VALUES (30, 1, 'table_b_test3');
|
||||
INSERT INTO table_b VALUES (40, 2, 'table_b_test4');
|
||||
|
||||
CREATE TABLE table_c (
|
||||
id SERIAL PRIMARY KEY,
|
||||
table_b_id integer NOT NULL,
|
||||
alias varchar(255) DEFAULT ''
|
||||
);
|
||||
|
||||
INSERT INTO table_c VALUES (100, 10, 'table_c_test1');
|
||||
INSERT INTO table_c VALUES (200, 10, 'table_c_test2');
|
||||
INSERT INTO table_c VALUES (300, 20, 'table_c_test3');
|
||||
INSERT INTO table_c VALUES (400, 30, 'table_c_test4');
|
||||
4
contrib/drivers/pgsql/testdata/with_tpl_user.sql
vendored
Normal file
4
contrib/drivers/pgsql/testdata/with_tpl_user.sql
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
CREATE TABLE IF NOT EXISTS %s (
|
||||
id SERIAL PRIMARY KEY,
|
||||
name varchar(45) NOT NULL
|
||||
);
|
||||
4
contrib/drivers/pgsql/testdata/with_tpl_user_detail.sql
vendored
Normal file
4
contrib/drivers/pgsql/testdata/with_tpl_user_detail.sql
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
CREATE TABLE IF NOT EXISTS %s (
|
||||
uid SERIAL PRIMARY KEY,
|
||||
address varchar(45) NOT NULL
|
||||
);
|
||||
5
contrib/drivers/pgsql/testdata/with_tpl_user_scores.sql
vendored
Normal file
5
contrib/drivers/pgsql/testdata/with_tpl_user_scores.sql
vendored
Normal file
@ -0,0 +1,5 @@
|
||||
CREATE TABLE IF NOT EXISTS %s (
|
||||
id SERIAL PRIMARY KEY,
|
||||
uid integer NOT NULL,
|
||||
score integer NOT NULL
|
||||
);
|
||||
Reference in New Issue
Block a user