Skip to content

Conversation

@Abdelrhmansersawy
Copy link
Contributor

fixes: #1099

Expand test coverage for reaper/database.go through handling:

  • query validation and error propagation
  • protocol selection for non‑Postgres sources
  • argument preservation for query execution
  • instance health checks via ping (up/down/PgBouncer)
  • extension creation decision paths (available/missing/query failure)

Test coverage improvements:

sersawy@omarchy ~/W/g/pgwatch (testcoverage_reaper)> rg "^total:" /tmp/cover.reaper.before.txt
                                                     rg "^total:" /tmp/cover.reaper.after.txt
61:total:                                                                                       (statements)                            56.5%
61:total:                                                                                       (statements)                            59.0%

@coveralls
Copy link

Pull Request Test Coverage Report for Build 21356387862

Details

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.8%) to 76.116%

Totals Coverage Status
Change from base Build 21290566757: 0.8%
Covered Lines: 4057
Relevant Lines: 5330

💛 - Coveralls

@Abdelrhmansersawy
Copy link
Contributor Author

@0xgouda
Could you please take a look and let me know if I’m heading in the right direction? I’m planning to complete this PR before moving on to other reaper files to improve coverage, unless you’d recommend working on them in parallel.

@0xgouda 0xgouda self-assigned this Jan 27, 2026
@0xgouda
Copy link
Collaborator

0xgouda commented Jan 27, 2026

@Abdelrhmansersawy

I don't understand whether this PR is ready for review or not. If not, please convert it to draft.

Anyway, I take a fast look and the TestQueryMeasurements... is repeated many times, shouldn't all tests for QueryMeasurements() go into a single function that tests different cases/scenarios?

Also please keep in mind this isn't about increasing test coverage but rather low test coverage hints that we have important paths not covered by tests, so you may consider adding integration tests under cmd/pgwatch/ and/or writing many scenarios to test the function not just covering the lines.

so for example, if database.go ended up with 80% coverage but we have tested all improtant/critical stuff we are golden.

@Abdelrhmansersawy
Copy link
Contributor Author

So, you want me to work on adding tests under cmd/pgwatch/ that test the whole system working together, not isolated units (e.g. database_test.go) ?

@0xgouda
Copy link
Collaborator

0xgouda commented Jan 27, 2026

So, you want me to work on adding tests under cmd/pgwatch/ that test the whole system working together, not isolated units (e.g. database_test.go) ?

Let's have a quick call, ping me on slack if you are active now.

@Abdelrhmansersawy
Copy link
Contributor Author

So, you want me to work on adding tests under cmd/pgwatch/ that test the whole system working together, not isolated units (e.g. database_test.go) ?

Let's have a quick call, ping me on slack if you are active now.

I have been ping you on slack now.

@Abdelrhmansersawy Abdelrhmansersawy marked this pull request as draft January 27, 2026 21:44
@pashagolub
Copy link
Collaborator

hey, would you please resolve if it's still up to date

@pashagolub pashagolub added the test New test case or request label Feb 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

test New test case or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Increase test coverage

4 participants