Skip to content

refactor: deduplicate remaining seed fixtures across server-test#1222

Merged
pyramation merged 4 commits into
mainfrom
feat/deduplicate-seed-fixtures
May 23, 2026
Merged

refactor: deduplicate remaining seed fixtures across server-test#1222
pyramation merged 4 commits into
mainfrom
feat/deduplicate-seed-fixtures

Conversation

@pyramation
Copy link
Copy Markdown
Contributor

@pyramation pyramation commented May 23, 2026

Summary

Consolidates remaining duplicated seed fixtures in graphql/server-test and removes all inline CREATE ROLE blocks from seed SQL.

Changes:

  • Deleted simple-seed/ entirely — tests now compose from base/setup.sql + root app-schemas/simple-pets/
  • Deleted schema-snapshot/setup.sql and search-seed/setup.sql — replaced with shared base/setup.sql
  • Created base/setup.sql — minimal shared layer (extensions + stamps schema)
  • Created search-seed/extensions.sql — search-specific extensions only (pg_trgm + pgvector)
  • Removed all inline DO $$ ... CREATE ROLE blocks from seed SQL — roles are created upstream by the CI workflow's pgpm admin-users bootstrap --yes step (and locally by running the same command before tests)
  • Updated 4 test files to reference shared fixtures
  • Updated README documenting the new layering and noting roles come from upstream

No changes to pgsql-client or pgsql-test — seed SQL just needed to stop duplicating what pgpm admin-users bootstrap already does.

Net: ~100 lines of duplicated SQL removed, zero CREATE ROLE in any seed file.

Review & Testing Checklist for Human

  • Verify no CREATE ROLE remains in any __fixtures__/seed/ file
  • Confirm CI workflow runs pgpm admin-users bootstrap --yes before the test steps (lines 226 and 334 of run-tests.yaml)
  • Run locally: pgpm admin-users bootstrap --yes && pgpm admin-users add --test --yes && cd graphql/server-test && pnpm test

Notes

  • Upload tests (7 tests) require MinIO which is only available in CI — the 1 local failure is expected
  • services/setup.sql previously had app_user/app_admin roles that were never referenced — removed along with the other role creation blocks

Link to Devin session: https://app.devin.ai/sessions/2b5a29d83d3f478e8d3d972653b4879c
Requested by: @pyramation

Extract shared base/setup.sql (roles, uuid-ossp, stamps) from the
repeated setup.sql files in simple-seed/, schema-snapshot/, and
search-seed/.

Changes:
- Add __fixtures__/seed/base/setup.sql — minimal base layer
- Delete simple-seed/ entirely — tests now compose from base/setup.sql
  + root app-schemas/simple-pets/ (schema + test-data)
- Delete schema-snapshot/setup.sql — tests now use base/setup.sql
- Replace search-seed/setup.sql with search-seed/extensions.sql
  containing only pg_trgm + optional pgvector (unique content)

Updated test files:
- server.integration.test.ts — simple-seed scenarios use shared base
- cli-e2e.test.ts — both simple-seed and search-seed use shared base
- search.integration.test.ts — uses shared base + local extensions
- schema-snapshot.test.ts — uses shared base

Remaining local fixtures (unique content, not shareable):
- search-seed/ — extensions.sql, schema.sql, test-data.sql
- schema-snapshot/ — schema.sql, test-data.sql
- simple-seed-storage/ — storage module setup, schema, test-data
@devin-ai-integration
Copy link
Copy Markdown
Contributor

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

Remove all inline CREATE ROLE blocks from seed SQL fixtures.
Roles (administrator, authenticated, anonymous) are now created by
pgsql-test's getConnections() via DbAdmin.createBaseRoles(), which
delegates to generateCreateBaseRolesSQL() from @pgpmjs/core.

This eliminates the DO $$ ... IF NOT EXISTS ... CREATE ROLE pattern
that can cause lock issues, and aligns with the pgpm role management
workflow.
@blacksmith-sh

This comment has been minimized.

When parallel CI test suites call createBaseRoles simultaneously,
the ALTER ROLE in generateCreateBaseRolesSQL can race and fail with
'tuple concurrently updated'. Add retry loop (3 attempts) to handle
this transient concurrency error.
…otstrap

The CI workflow already runs 'pgpm admin-users bootstrap' before tests,
which creates the base roles (administrator, authenticated, anonymous).
No code changes needed in pgsql-client or pgsql-test — the seed SQL
just needed to stop duplicating what the workflow already does.
@pyramation pyramation merged commit 97576c2 into main May 23, 2026
37 checks passed
@pyramation pyramation deleted the feat/deduplicate-seed-fixtures branch May 23, 2026 20:08
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.

1 participant