0

I am testing my supabase table using pgtap and supabase test helpers

I have a table posts with a creator uuid and a published boolean field. My row level policy checks that creators of a post are always allowed to see it, regardless if published or not. Anonymous users are only allowed to see a post when it has been published. This works as intended.

How can I test this behavior with pgtap? I tried using is(), but this allows me only to check for one of the two constraints and not combine both using OR.

I would need something like: is(creator, tests.get_supabase_uid('test_owner') -> 'id') OR is(published, true) FROM posts

JoJota
  • 35
  • 10

1 Answers1

0

There is a 3rd party guide available for testing supabase RLS policies here

Check out the section "Testing your RLS Policies"

It references supabase-test-helpers but you can copy out the functions you need if you'd prefer not to use it.

Oliver Rice
  • 768
  • 8
  • 20