docs(tests): add test coverage plans
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
# Plan: PostgreSQL
|
||||
|
||||
## Tooling
|
||||
- Live tests: `tests/dbtest/dbtest.sh test postgres` (defaults to readers/pgsql, writers/pgsql, writers/sqlexec) or `up postgres` + `eval "$(tests/dbtest/dbtest.sh env postgres)"`.
|
||||
- Isolation: each live test creates and drops its own schema; shared fixture DB comes from `init.sql`.
|
||||
|
||||
## Existing
|
||||
- Reader tests: `pkg/readers/pgsql/reader_test.go` (live tests skipped without `RELSPEC_TEST_PG_CONN`; pure tests: MapDataType, ParseIndexDefinition, DeriveRelationship, composite FK)
|
||||
- Writer tests: diff_statements, directives, extensions, generated_column, migration_writer, serial_sequence
|
||||
- Data: `tests/postgres/init.sql`, `tests/postgres/issue21`, `tests/assets/dbml/*`, `examples/test_schema*.dbml`
|
||||
|
||||
## readers/pgsql (16.0%)
|
||||
|
||||
| Item | Gap | Approach |
|
||||
|------|-----|----------|
|
||||
| `normalizePostgresDefault` (queries.go) | 0% | Pure; table-driven: casts, nextval, functions, quoted literals, NULL |
|
||||
| `countColumns/Constraints/Indexes` | 0% | Pure; build Database fixtures |
|
||||
| `ReadDatabase/ReadSchema/ReadTable` | ~0% | Live; run against `init.sql` DB; assert counts, PK/FK/unique/check/index, views, sequences, extensions |
|
||||
| `query*` (11 funcs) | 0% | Covered via live ReadDatabase; add one live case per object type |
|
||||
| `close` | 0% | Live; connection released after read and on error |
|
||||
|
||||
Data needed: extend `tests/postgres/init.sql` (loaded by dbtest on `up`; apply changes with `dbtest.sh restart postgres`) with a view, sequence, check constraint, partial index, extension, composite FK (verify what already exists first).
|
||||
|
||||
## writers/pgsql (74.0%)
|
||||
|
||||
| Item | Gap | Approach |
|
||||
|------|-----|----------|
|
||||
| `extractTableNameFromCreate`, `extractStatementContext`, `extractSQLStringValue`, `parseQualifiedIdent`, `firstBareIdent`, `firstIdentAfterKeyword`, `stripQuotes`, `buildStmtContext`, `detectStatementType`, `truncateStatement` | 0% | Pure; table-driven; quoted/qualified/unquoted idents, each statement type, long statements |
|
||||
| `getCurrentTimestamp`, `finishReport`, `writeReport` | 0% | Report written to temp file; JSON shape, counts, failed statements |
|
||||
| `executeStatements`, `executeDatabaseSQL` | 0% | Live; success, failure with continue-on-error, failure stop, report output |
|
||||
| `generateLiveDiffStatements` | 28.6% | Live; empty DB, drifted DB, identical DB |
|
||||
| `currentColumnHasDescription`, `ExecuteCommentColumn` | 0% | Migration writer fixtures with comments added/removed/changed |
|
||||
| `template_functions.go` `filter`, `mapFunc` | 0% | Pure |
|
||||
|
||||
Reuse `tests/integration/failed_statements_example.txt` for failed-statement report cases. Ad-hoc SQL setup: `dbtest.sh exec postgres <file>`.
|
||||
|
||||
## pkg/pgsql (87.8%)
|
||||
- Spot-check uncovered funcs after the above; add keyword/datatype edge cases only.
|
||||
Reference in New Issue
Block a user