Repository navigation
feat(pgtap): replace skeleton with 3 proper pgTAP smoke tests #421
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
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
2d130cf
feat(pgtap): replace skeleton with 3 proper pgTAP smoke tests (#416)
flyingrobots 6efd455
fix(pgtap): correct sanitized names, add Docker local testing
flyingrobots 6f7b3a6
fix(cli): add graphql as direct dependency of @wesley/cli
flyingrobots ce2afb9
fix(pgtap): resolve self-review findings on #416 PR
flyingrobots fd9f489
fix(pgtap): parse TAP output so assertion failures fail CI
flyingrobots 603a2b0
fix(pgtap): strengthen assertions per CodeRabbit review feedback
flyingrobots 6ed2a49
refactor(ci): deduplicate seed data — CI reads 03-seed.sql directly
flyingrobots 922d4ba
fix(pgtap): address CodeRabbit trivial nits from re-review
flyingrobots 681d3ae
Merge remote-tracking branch 'origin/main' into feat/pgtap-smoke-test…
flyingrobots File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| query AllProducts { | ||
|
flyingrobots marked this conversation as resolved.
|
||
| products(orderBy: [{ name: asc }]) { | ||
| id | ||
| name | ||
| slug | ||
| price_cents | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,70 @@ | ||
| -- pgTAP smoke tests: nested LATERAL join (orders_with_items_by_user.op.json) | ||
| -- Tests that a LATERAL join operation emits a function with nested jsonb arrays. | ||
|
|
||
| BEGIN; | ||
| SELECT plan(7); | ||
|
|
||
| -- 1. Schema exists | ||
| SELECT has_schema('wes_ops', 'wes_ops schema exists'); | ||
|
|
||
| -- 2. Function exists with uuid parameter | ||
| SELECT has_function( | ||
| 'wes_ops', 'op_orders_with_items_by_user', ARRAY['uuid'], | ||
| 'op_orders_with_items_by_user(uuid) function exists' | ||
| ); | ||
|
|
||
| -- 3. Seeded user has 1 order | ||
| SELECT is( | ||
| (SELECT count(*)::bigint FROM wes_ops.op_orders_with_items_by_user( | ||
| '00000000-0000-0000-0000-000000000001'::uuid | ||
| )), | ||
| 1::bigint, | ||
| 'op_orders_with_items_by_user returns 1 order for seeded user' | ||
| ); | ||
|
coderabbitai[bot] marked this conversation as resolved.
|
||
|
|
||
| -- 4. Negative case: non-existent user returns 0 rows (proves user_id predicate works) | ||
| SELECT is( | ||
| (SELECT count(*)::bigint FROM wes_ops.op_orders_with_items_by_user( | ||
| '00000000-0000-0000-0000-000000000002'::uuid | ||
| )), | ||
| 0::bigint, | ||
| 'op_orders_with_items_by_user returns 0 orders for non-existent user' | ||
| ); | ||
|
|
||
| -- 5. Returned jsonb has expected top-level keys (id, order_number, status, items) | ||
| SELECT ok( | ||
| (SELECT bool_and( | ||
| row_data ? 'id' | ||
| AND row_data ? 'order_number' | ||
| AND row_data ? 'status' | ||
| AND row_data ? 'items' | ||
| ) FROM wes_ops.op_orders_with_items_by_user( | ||
| '00000000-0000-0000-0000-000000000001'::uuid | ||
| ) AS row_data), | ||
| 'every row has id, order_number, status, items keys' | ||
| ); | ||
|
|
||
| -- 6. Every order's nested items array has 2 order items | ||
| SELECT ok( | ||
| (SELECT bool_and(jsonb_array_length(row_data -> 'items') = 2) | ||
| FROM wes_ops.op_orders_with_items_by_user( | ||
| '00000000-0000-0000-0000-000000000001'::uuid | ||
| ) AS row_data), | ||
| 'all orders have exactly 2 items' | ||
| ); | ||
|
|
||
| -- 7. Each nested item has required keys (id, product_id, quantity) | ||
| SELECT ok( | ||
| (SELECT bool_and( | ||
| elem ? 'id' | ||
| AND elem ? 'product_id' | ||
| AND elem ? 'quantity' | ||
| ) FROM wes_ops.op_orders_with_items_by_user( | ||
| '00000000-0000-0000-0000-000000000001'::uuid | ||
| ) AS row_data, | ||
| LATERAL jsonb_array_elements(row_data -> 'items') AS elem), | ||
| 'every nested item has id, product_id, quantity keys' | ||
| ); | ||
|
|
||
| SELECT finish(); | ||
| ROLLBACK; | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.