Skip to content

[+] add SQL test coverage with pgcov - #850

Open
pashagolub wants to merge 7 commits into
fix/cron-split-hintfrom
feat/sql-coverage-pgcov
Open

pashagolub wants to merge 7 commits into
fix/cron-split-hintfrom
feat/sql-coverage-pgcov

Conversation

@pashagolub

@pashagolub pashagolub commented Sep 22, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Stacked on #863, which fixes the bug these tests found. Merge #863 first.

Adds tests for the schema SQL. pgcov v0.0.1 runs them and the coverage goes to Coveralls.

 internal/pgengine/sql/
 ├── init.sql
+├── cron_test.sql           # DO/ASSERT tests, next to the script they cover
+├── ddl_test.sql
+├── job_functions_test.sql
+└── json_schema_test.sql

The *_test.sql files are not embedded, so the Go build does not change. secrets_test.go skips them in its DDL scan. Error cases go through a pg_temp.raises(stmt, expected_state) helper.

The new test-sql CI job:

test-sql (PostgreSQL 18 service)
  go install .../pgcov/cmd/pgcov@v0.0.1
  pgcov run . --source init → cron → ddl → json_schema → job_functions   # bootstrap order
  pgcov report --format=lcov → Coveralls, flag "sql"
coverage
  carries the "sql" flag forward

.pgcov/ (pgcov's local output) goes into .gitignore.

Evidence

Merge Danger

Door: two-way

Only tests, CI and .gitignore change. Reverting the PR removes them.

Blast Radius: CI

The new test-sql job and the sql Coveralls flag can fail or change the coverage numbers on other PRs. No runtime code changes.

Known pgcov limitations (follow-ups)

  • RAISE EXCEPTION paths show as uncovered, because NOTIFY is transactional.
  • LCOV counts plain DDL lines as hit, so the Coveralls sql number is higher than pgcov's executable percentage.

@coveralls

coveralls commented Sep 22, 2026 •

Copy link
Copy Markdown

Coverage Report for CI Build 37968521412

Warning

No base build found for commit 5532bdc on fix/cron-split-hint.
Coverage changes can't be calculated without a base build.
If a base build is processing, this comment will update automatically when it completes.

Coverage: 87.931%

Details

  • Patch coverage: No coverable lines changed in this PR.

Uncovered Changes

No uncovered changes found.

Coverage Regressions

Requires a base build to compare against. How to fix this →


Coverage Stats

Coverage Status
Relevant Lines: 2552
Covered Lines: 2244
Line Coverage: 87.93%
Coverage Strength: 0.9 hits per line

💛 - Coveralls

@pashagolub pashagolub self-assigned this Sep 22, 2026
@pashagolub pashagolub added enhancement New feature or request test New test case or request labels Sep 22, 2026
@pashagolub pashagolub changed the title Add SQL test coverage with pgcov [+] add SQL test coverage with pgcov Sep 22, 2026
Adds *_test.sql files next to the schema scripts and a CI job that runs
them with pgcov against a PostgreSQL service, reporting LCOV to Coveralls
under the 'sql' flag.

cron_test.sql intentionally fails until cron.sql is fixed: the RAISE
EXCEPTION hint concatenates strings with + instead of ||, so unrecognised
cron values raise 42725 instead of the intended message.
The hint was built with `+` instead of `||`, so an unrecognized cron
value raised 42725 (operator does not exist) instead of the intended
'Value ("...") not recognized' error. Found by cron_test.sql under pgcov.

Migration 00850 replaces the function on existing installations.
The pgcrypto scan in secrets_test.go now skips *_test.sql scripts,
which are not shipped.
@pashagolub
pashagolub force-pushed the feat/sql-coverage-pgcov branch from 8ea1c4d to 761db50 Compare October 7, 2026 18:14
@pashagolub
pashagolub marked this pull request as ready for review October 9, 2026 17:19
@pashagolub
pashagolub changed the base branch from master to fix/cron-split-hint October 9, 2026 17:45
@pashagolub
pashagolub added this pull request to stack #864 October 9, 2026 17:48
@postgresql007
postgresql007 self-requested a review October 9, 2026 19:46

@postgresql007 postgresql007 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request test New test case or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants