test(supabase): make pgTAP counts seed-agnostic (real stack carries seed accounts)
This commit is contained in:
1 parent
d5a5a720a1
commit
a2e33fe4a2
2 files changed
+28
-8
No files matched your search
@@ -109,8 +109,19 @@ select is((select count(*) from public.profiles), 1::bigint, 'plain user still s
|
||||
|
||||
-- 6. Admin sees every grant and every profile (staff read)
|
||||
select set_config('request.jwt.claims', '{"sub":"00000000-0000-0000-0000-00000000000a","role":"authenticated"}', true);
|
||||
select is((select count(*) from public.profile_roles), 3::bigint, 'admin sees all three grant rows');
|
||||
select is((select count(*) from public.profiles), 4::bigint, 'admin reads every profile');
|
||||
select is(
|
||||
(select count(*) from public.profile_roles
|
||||
where user_id in ('00000000-0000-0000-0000-000000000001', '00000000-0000-0000-0000-00000000000a', '00000000-0000-0000-0000-00000000000b')),
|
||||
3::bigint,
|
||||
'admin sees all three fixture grant rows'
|
||||
);
|
||||
select is(
|
||||
(select count(*) from public.profiles where id in (
|
||||
'00000000-0000-0000-0000-000000000001', '00000000-0000-0000-0000-00000000000a',
|
||||
'00000000-0000-0000-0000-00000000000b', '00000000-0000-0000-0000-00000000000c')),
|
||||
4::bigint,
|
||||
'admin reads every fixture profile'
|
||||
);
|
||||
|
||||
-- 7. Anonymous
|
||||
set local role anon;
|
||||
@@ -135,7 +146,9 @@ reset role;
|
||||
update public.profiles set active = false where id = '00000000-0000-0000-0000-00000000000a';
|
||||
select ok(not private.is_platform_admin('00000000-0000-0000-0000-00000000000a'), 'deactivated account loses its roles');
|
||||
|
||||
-- 9. Last-owner guard on the system path
|
||||
-- 9. Last-owner guard on the system path (neutralise owners seeded outside the fixtures)
|
||||
update public.profile_roles set revoked_at = now()
|
||||
where role = 'owner' and revoked_at is null and user_id <> '00000000-0000-0000-0000-000000000001';
|
||||
select throws_ok(
|
||||
$$ select private.withdraw_platform_role(null, '00000000-0000-0000-0000-000000000001', 'owner', 'oops') $$,
|
||||
'42501',
|
||||
|
||||
Reference in new issue
Block a user