Skip to content

Conversation

MatthewCane
Copy link
Contributor

@MatthewCane MatthewCane commented Jul 4, 2025

Resolves #444.

  • Introduced --expect-table option to check for the existence of a database table before completing
  • Works for MySQL and Postgres
  • Added tests for scenarios where a specified table exists and does not exist

- Implemented `WithTableExists` option to configure table existence checks.
- Added tests for scenarios where a table exists and does not exist.
- Updated command to accept a `--table-exists` flag for checking table presence in the database.
- Introduced `WithTableExists` option to allow configuration of table existence checks.
- Added tests for scenarios where a specified table exists and does not exist.
- Updated MySQL command to support a `--table-exists` flag for checking table presence in the database.
@atkrad atkrad self-requested a review July 5, 2025 20:12
@atkrad atkrad added the feature New feature or request label Jul 5, 2025
@atkrad
Copy link
Member

atkrad commented Jul 5, 2025

Hi @MatthewCane,

Thanks for your contribution! I think it would be better to rename the --table-exists flag to --expect-table, to keep the naming consistent with other commands like HTTP, Redis and etc. What do you think?

Also, it looks like the MySQL unit tests failed. Could you please check that?

@atkrad
Copy link
Member

atkrad commented Jul 5, 2025

@MatthewCane, regarding the unit tests — please let me know if you need any help.

@MatthewCane
Copy link
Contributor Author

Thank you for the feedback @atkrad, I agree on the flag naming and I have adjusted it accordingly. I have hopefully fixed the tests and added a small extra line to the setup of the database test containers to hopefully make the tests more reliable, I've had a few flakey failures:

testcontainers.WithWaitStrategy(wait.ForListeningPort("XXXXX"))

@coveralls
Copy link

coveralls commented Jul 7, 2025

Pull Request Test Coverage Report for Build 16142558891

Details

  • 45 of 58 (77.59%) changed or added relevant lines in 4 files are covered.
  • 1 unchanged line in 1 file lost coverage.
  • Overall coverage increased (+0.5%) to 55.867%

Changes Missing Coverage Covered Lines Changed/Added Lines %
checker/mysql/mysql.go 20 22 90.91%
checker/postgresql/postgresql.go 20 22 90.91%
internal/cmd/mysql.go 5 7 71.43%
internal/cmd/postgresql.go 0 7 0.0%
Files with Coverage Reduction New Missed Lines %
internal/cmd/postgresql.go 1 0.0%
Totals Coverage Status
Change from base Build 15880517635: 0.5%
Covered Lines: 1357
Relevant Lines: 2429

💛 - Coveralls

atkrad

This comment was marked as resolved.

@atkrad atkrad self-requested a review July 8, 2025 11:59
@atkrad atkrad merged commit 84cac9e into wait4x:main Jul 8, 2025
3 of 4 checks passed
@MatthewCane
Copy link
Contributor Author

Thank you for catching those! This feature is going to be really useful for me so I'm very happy I could contribute.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Feature Request: Optionally check for the existence of a database table when connecting to a database
3 participants