test: add database CI workflow and PGTap tests for invite_organization_member#1506
Conversation
|
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
1 Skipped Deployment
|
|
Updates to Preview Branch (test-db-functions-2) ↗︎
Tasks are run on every commit but only new migration files are pushed.
View logs for this Workflow Run ↗︎. |
c19fb23 to
e4fb66e
Compare
…n_member - Introduced a GitHub Actions workflow `.github/workflows/database-ci.yml` to run PGTap tests - Created setup-testing.sql to provision test users and support functions - Added initial test file `01-invite_organization_member.test.sql` for the `invite_organization_member` RPC function - Included a shell script `run-tests.sh` to streamline local testing - Tests cover new user invitation, duplicate prevention, case-insensitive matching, and timestamp updates
e4fb66e to
94b3a41
Compare
PR Reviewer Guide 🔍Here are some key observations to aid the review process:
|
PR Code Suggestions ✨Explore these optional code suggestions:
|
|||||||||||
MH4GF
left a comment
There was a problem hiding this comment.
LGTM, but I wrote a comment!
There was a problem hiding this comment.
I am uncomfortable with the placement of this file in .github/workflows, do you think it is frontend/packages/db/supabase/tests?
There was a problem hiding this comment.
frontend/packages/db/supabase/tests
the original is https://github.com/usebasejump/basejump/tree/main/.github/workflows , but , I think frontend/packages/db/supabase/tests is more reasonable! 👍
I'll fix it
Issue
Why is this change needed?
Adding Database CI Workflow and PGTap Tests.
Purpose of the Changes
This change establishes an automated testing environment for database functions, specifically for the
invite_organization_memberRPC function. This enhancement strengthens quality assurance for database functions and enables database tests to be run as part of the continuous integration (CI) process.Intent of the Changes
CI and Local Testing Environment Setup
GitHub Actions Workflow
Added
.github/workflows/database-ci.ymlto automatically run database tests under the following conditions:This workflow starts a Supabase environment, performs test setup, and then runs PGTap tests.
Test Environment Setup
Created
.github/workflows/setup-testing.sqlto provide the following features needed for test execution:Local Testing Script
Added
frontend/packages/db/supabase/tests/run-tests.shto allow developers to easily run tests in their local environment. This script provides the following functionality:Testing Implementation for invite_organization_member Function (01-invite_organization_member.test.sql)
Implemented tests using PGTap in
frontend/packages/db/supabase/tests/database/01-invite_organization_member.test.sql. This test file covers the following test cases:New User Invitation: Verifies that a new member can be invited to an organization
Duplicate Prevention: Verifies that an error is returned when attempting to invite a user who is already a member of the organization
Re-invitation Functionality: Verifies the behavior when re-inviting a user who already has a pending invitation
Case Insensitivity: Verifies that email addresses are processed correctly regardless of case
Timestamp Update: Verifies that the
invited_attimestamp is appropriately updated during re-invitationThese tests ensure that the main functionality and edge cases of the
invite_organization_memberfunction are properly covered.Future Outlook
Building on this infrastructure, we plan to gradually add tests for other database functions. This will improve the overall quality and reliability of the database layer.
What would you like reviewers to focus on?
invite_organization_membercover the expected edge cases and typical usage patterns appropriately.github/workflows/database-ci.ymlcorrectly integrates with GitHub Actions and runs the database tests as intendedsetup-testing.sqlscript safely prepares the test environment without affecting production schema or datarun-tests.sh, including its robustness in various local setupsTesting Verification
What was done
🤖 Generated by PR Agent at 94b3a41
invite_organization_memberfunction.Detailed Changes
database-ci.yml
Add GitHub Actions workflow for database CI and PGTap tests.github/workflows/database-ci.yml
01-invite_organization_member.test.sql
Add PGTap tests for invite_organization_member RPC functionfrontend/packages/db/supabase/tests/database/01-invite_organization_member.test.sql
invite_organization_member.insensitivity.
setup-testing.sql
Add SQL setup for PGTap and test user utilities.github/workflows/setup-testing.sql
run-tests.sh
Add shell script for local database test automationfrontend/packages/db/supabase/tests/run-tests.sh
Additional Notes