Skip to content

test: consolidate cdc_rls extension tests into test/extensions/postgres_cdc_rls - #2230

Open
akshar27 wants to merge 1 commit into
supabase:mainfrom
akshar27:test/consolidate-cdc-rls-extension-tests
Open

akshar27 wants to merge 1 commit into
supabase:mainfrom
akshar27:test/consolidate-cdc-rls-extension-tests

Conversation

@akshar27

Copy link
Copy Markdown

Summary

Closes #2223.

The postgres_cdc_rls extension code lives in lib/extensions/postgres_cdc_rls/, but its tests were split across two trees, neither of which matched that path:

  • test/extensions/postgres_cdc_rls/ — partial, matches lib/
  • test/realtime/extensions/cdc_rls/ — the rest, adds a realtime/ prefix lib/ doesn't have and shortens postgres_cdc_rls to cdc_rls

Because the paths didn't line up, a broken function could still show a green run against the wrong test file.

What changed

Moved the five non-overlapping files from test/realtime/extensions/cdc_rls/ into test/extensions/postgres_cdc_rls/ as straight renames (no content changes):

  • cdc_rls_test.exs
  • replication_poller_test.exs
  • subscription_manager_distributed_test.exs
  • subscription_manager_test.exs
  • subscriptions_test.exs

replications_test.exs existed in both trees, testing the same module from different angles, so per the issue this one was merged rather than overwritten:

  • Kept the canonical version's describe blocks: prepare_replication/2, terminate_backend/2, get_pg_stat_activity_diff/2, and the five list_changes/5 slot_changes_count scenarios.
  • Added the two describe blocks the other copy had that the canonical one didn't: drop_replication_slot/2 (not covered at all in the canonical file) and list_changes for schemas/tables with special characters (spaces, commas, quotes, emoji, etc. — also not covered in the canonical file).
  • Tests where both files covered the same behavior (just with different setup styles) were not duplicated — canonical's versions already exercise that behavior.

test/realtime/api/extensions_test.exs is left where it is, per the issue — it covers lib/realtime/api/extensions.ex, a different module.

No production code changed.

Test plan

mix test test/extensions/postgres_cdc_rls/ against a local realtime + tenant Postgres (via mix setup && mise run db-start): 12 doctests, 205 tests, 0 failures. Same test count/coverage as the sum of both trees before the merge, minus the genuinely duplicated cases.

mix format --check-formatted and mix credo --strict both clean.

…es_cdc_rls

The extension code lives in lib/extensions/postgres_cdc_rls/, but its tests
were split across two trees that neither matched that path:

  test/extensions/postgres_cdc_rls/   (partial, matches lib/)
  test/realtime/extensions/cdc_rls/   (the rest, path doesn't match anything)

Because the paths didn't line up, a broken function could still show a green
run against the wrong test file.

Move the five non-overlapping files into the canonical location. For
replications_test.exs, which existed in both trees testing the same module
from different angles, merge rather than overwrite: keep the canonical
version's describe blocks (prepare_replication/2, terminate_backend/2,
get_pg_stat_activity_diff/2, the five list_changes/5 slot_changes_count
scenarios) and add the two describe blocks the other copy covered and the
canonical one didn't (drop_replication_slot/2, and list_changes for schemas
and tables with special characters). Tests already covering the same
behaviour in both files were not duplicated.

test/realtime/api/extensions_test.exs is left where it is, per the issue -
it covers lib/realtime/api/extensions.ex, a different module.

No production code changed. mix test test/extensions/postgres_cdc_rls/
passes: 12 doctests, 205 tests, 0 failures.

Closes supabase#2223
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.

Consolidate extension tests into one canonical location mirroring lib/

1 participant