Add map import and export with durable refresh progress
This commit is contained in:
38
tests/sql/map-sharing.sql
Normal file
38
tests/sql/map-sharing.sql
Normal file
@@ -0,0 +1,38 @@
|
||||
begin;
|
||||
do $$
|
||||
declare owner uuid:=gen_random_uuid(); friend uuid:=gen_random_uuid(); other uuid:=gen_random_uuid(); original uuid; copy uuid; manifest jsonb; sid uuid; rid uuid; before_games integer;
|
||||
begin
|
||||
before_games:=(public.player_leaderboard()->>'total_games')::integer;
|
||||
insert into auth.users(id) values(owner),(friend),(other);
|
||||
insert into public.profiles(id) values(owner),(friend),(other) on conflict(id) do nothing;
|
||||
manifest:='{"format":"minegeo-dataset/v1","source":"plugin","mediaFormat":"webp","name":"Shared fixture","description":"","serverName":"Shared fixture server","bounds":{"minX":0,"minZ":0,"maxX":64,"maxZ":64},"viewpoints":[{"id":"p0","x":0,"y":70,"z":0},{"id":"p1","x":1,"y":70,"z":1},{"id":"p2","x":2,"y":70,"z":2},{"id":"p3","x":3,"y":70,"z":3},{"id":"p4","x":4,"y":70,"z":4}],"assets":[]}';
|
||||
original:=public.create_upload(owner,manifest);
|
||||
update public.dataset_inputs set validated=true where dataset_id=original;
|
||||
update public.datasets set state='draft',panorama_count=5 where id=original;
|
||||
copy:=public.create_map_import(friend,manifest,original,'Original owner');
|
||||
update public.dataset_inputs set validated=true where dataset_id=copy;
|
||||
update public.datasets set state='draft',panorama_count=5 where id=copy;
|
||||
sid:=public.create_game(copy,'normal',friend,'private-fixture');
|
||||
if (select count(*) from public.game_rounds where session_id=sid)<>5 then raise exception 'Private game was not created'; end if;
|
||||
rid:=public.create_map_room(copy,'easy','Friend',4,repeat('a',64),friend);
|
||||
if (select count(*) from public.multiplayer_rounds where room_id=rid)<>5 then raise exception 'Private room was not created'; end if;
|
||||
begin perform public.create_game(copy,'normal',other,'unauthorized'); raise exception 'Other account played private map';
|
||||
exception when others then if sqlerrm<>'Map unavailable' then raise; end if; end;
|
||||
begin perform public.create_game(copy,'normal',null,'guest'); raise exception 'Guest played private map';
|
||||
exception when others then if sqlerrm<>'Map unavailable' then raise; end if; end;
|
||||
begin perform public.create_map_room(copy,'easy','Other',4,repeat('b',64),other); raise exception 'Other account hosted private map';
|
||||
exception when others then if sqlerrm<>'Map unavailable' then raise; end if; end;
|
||||
begin perform public.submit_draft(copy,friend); raise exception 'Friend submitted imported map';
|
||||
exception when others then if sqlerrm not like 'Owned by "Original owner".%' then raise; end if; end;
|
||||
begin update public.datasets set state='published' where id=copy; raise exception 'Shared map published';
|
||||
exception when others then if sqlerrm not like 'Owned by "Original owner".%' then raise; end if; end;
|
||||
begin update public.datasets set imported_from_id=null,imported_owner_name=null where id=copy; raise exception 'Attribution removed';
|
||||
exception when others then if sqlerrm<>'Shared map ownership cannot be changed' then raise; end if; end;
|
||||
perform public.submit_draft(original,owner);
|
||||
if (select state from public.datasets where id=original)<>'review' then raise exception 'Original owner cannot submit'; end if;
|
||||
if (select state from public.datasets where id=copy)<>'draft' then raise exception 'Private copy changed'; end if;
|
||||
update public.game_rounds set result='{"score":5000}' where session_id=sid;
|
||||
update public.game_sessions set current_round=5 where id=sid;
|
||||
if (public.player_leaderboard()->>'total_games')::integer<>before_games then raise exception 'Private scores reached public leaderboard'; end if;
|
||||
end; $$;
|
||||
rollback;
|
||||
Reference in New Issue
Block a user