@davoodmehraban89 / LifeMate / commits / 3303c94
Fork 0

LifeMate — Personal, Family & Learning Companion

test: add database authorization smoke assertions

davoodmehraban89 committed Oct 5, 2026 at 07:31 UTC 3303c942929f12d6f8766d16414e12c7d5280fa7
1 file changed +28
backend/tests/schema_test.sql new
+28
@@ -0,0 +1,28 @@
1 +\set ON_ERROR_STOP on
2 +
3 +begin;
4 +
5 +insert into app_user(id, identity_subject, email_normalized) values
6 +('00000000-0000-0000-0000-000000000001','parent-1','parent@example.test'),
7 +('00000000-0000-0000-0000-000000000002','teen-1','teen@example.test'),
8 +('00000000-0000-0000-0000-000000000003','other-1','other@example.test');
9 +
10 +insert into family_workspace(id,name,created_by) values
11 +('10000000-0000-0000-0000-000000000001','Test Family','00000000-0000-0000-0000-000000000001');
12 +
13 +insert into family_membership(family_id,user_id,role) values
14 +('10000000-0000-0000-0000-000000000001','00000000-0000-0000-0000-000000000001','parent_guardian'),
15 +('10000000-0000-0000-0000-000000000001','00000000-0000-0000-0000-000000000002','teen_minor');
16 +
17 +insert into guardian_relationship(family_id,guardian_user_id,minor_user_id) values
18 +('10000000-0000-0000-0000-000000000001','00000000-0000-0000-0000-000000000001','00000000-0000-0000-0000-000000000002');
19 +
20 +do $$
21 +begin
22 + if not is_active_family_member('10000000-0000-0000-0000-000000000001','00000000-0000-0000-0000-000000000002') then raise exception 'teen must be active family member'; end if;
23 + if is_active_family_member('10000000-0000-0000-0000-000000000001','00000000-0000-0000-0000-000000000003') then raise exception 'outsider must not be family member'; end if;
24 + if not is_active_guardian('10000000-0000-0000-0000-000000000001','00000000-0000-0000-0000-000000000001','00000000-0000-0000-0000-000000000002') then raise exception 'guardian relation missing'; end if;
25 + if is_active_guardian('10000000-0000-0000-0000-000000000001','00000000-0000-0000-0000-000000000003','00000000-0000-0000-0000-000000000002') then raise exception 'outsider must not become guardian'; end if;
26 +end $$;
27 +
28 +rollback;