Skip to content

test: introduce test-db #149

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

juleswritescode
Copy link
Collaborator

@juleswritescode juleswritescode commented Nov 26, 2024

This PR introduces a pg_test_utils crate.

It contains a get_new_test_db function that'll create a new database against a connected postgres instance. We can use that database for testing; e.g. insert a table and test whether the autocompletion works correctly. We assert that the postgres instance runs on either localhost or 127.0.0.1. Note: the test databases aren't automatically cleaned up, but can simply be removed with docker.

I stole the uuid approach from here.

Additionally:

  • I changed the DB_CONNECTION_STRING env var to DATABASE_URL, which was already set and required for sqlx
  • I ensured that all crates use the workspace's sqlx version
  • I updated the packages in the root Cargo.toml because I had dependency conflicts between tokio and threadpool

Next up, I'll write some proper tests for the pg_completions crate. :)

@juleswritescode juleswritescode marked this pull request as ready for review November 27, 2024 07:15
@psteinroe psteinroe merged commit ab3712d into supabase-community:main Nov 30, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants