Skip to content

Test roles: single source of truth with quoting-requiring names#45

Open
jnasbyupgrade wants to merge 1 commit into
Postgres-Extensions:masterfrom
jnasbyupgrade:roles-quoting-single-source
Open

Test roles: single source of truth with quoting-requiring names#45
jnasbyupgrade wants to merge 1 commit into
Postgres-Extensions:masterfrom
jnasbyupgrade:roles-quoting-single-source

Conversation

@jnasbyupgrade

Copy link
Copy Markdown
Contributor

Improve the test suite's role handling. Test-harness only: no extension SQL or versioned files change, and it is independent of #44 (it applies to master's existing per-test role-creation model regardless of that PR).

What changed

  • test/roles.sql (new): single source of truth for the two test-role names, \i'd per test by test/deps.sql. Previously the names were hard-coded inline.
  • Rename the roles from cat_tools_testing__use_role / __no_use_role to "cat_tools testing: USE" / "cat_tools testing: NO USE" -- names that require identifier quoting. This is deliberate: with a quote-free name, a missing quote at a use site passes silently; with a name containing a space and mixed case, any unquoted reference (in a test or in the code under test) becomes a hard failure. So the names actively surface quoting bugs instead of hiding them.
  • Quote every reference accordingly (:"use_role" in identifier position): test/deps.sql (CREATE ROLE / GRANT), test/setup.sql (GRANT USAGE), and the SET LOCAL ROLE / GRANT sites in test/sql/{attribute,enum,extension,function,name__check,object_type,pg_depends,relation_type,sequence,trigger}.sql. test/sql/permissions.sql already used the quoted form; this change makes the names actually exercise it.

Why base master, not #44

The role naming/quoting/single-source change is an independent quality improvement to master's existing per-test role creation (test/deps.sql still creates the roles per test here). It does not need #44's committed-once installer, so it is based on master and can merge in either order.

Verified locally

make test on PG17: all 12 role-using tests pass with the quoting-requiring names. (The unrelated zzz_build build-sanity diff fails identically on pristine master -- a pre-existing stale expected file -- and make test is non-gating in CI regardless.)

🤖 Generated with Claude Code

@coderabbitai

coderabbitai Bot commented Jul 21, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 320e5bec-842c-4370-8795-31674b13a505

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Move the test-role names into one file, test/roles.sql, \i'd per test by test/deps.sql instead of hard-coding the names inline. Previously the names were spelled out in deps.sql and implied across the test files.

Rename the roles from cat_tools_testing__use_role / __no_use_role to "cat_tools testing: USE" / "cat_tools testing: NO USE" -- names that REQUIRE identifier quoting. The point is defensive: if the code under test (or a test) ever emits an unquoted role reference, the space/mixed-case name turns that latent quoting bug into a hard test failure instead of passing silently on a conveniently quote-free name. Every reference is quoted accordingly (:"use_role" in identifier position). test/sql/permissions.sql already used the quoted form; this makes the names actually exercise it, and brings the remaining test files and deps.sql/setup.sql into line.

Test-harness only: no extension SQL or versioned files change.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@jnasbyupgrade
jnasbyupgrade force-pushed the roles-quoting-single-source branch from 6c71b9f to 5382c20 Compare July 21, 2026 22:22
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