Skip to content

Commit

Permalink
Update sql unit tests badges
Browse files Browse the repository at this point in the history
  • Loading branch information
xbgmsharp committed Dec 3, 2024
1 parent 48bba3e commit 65455c9
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 4 deletions.
7 changes: 4 additions & 3 deletions tests/sql/badges.sql
Original file line number Diff line number Diff line change
Expand Up @@ -24,19 +24,17 @@ INSERT INTO api.logbook

\echo 'Set config'
SELECT set_config('user.email', '[email protected]', false);
--SELECT set_config('vessel.client_id', 'vessels.urn:mrn:imo:mmsi:123456789', false);

\echo 'Process badge'
SELECT badges_logbook_fn(5,NOW()::TEXT);
SELECT badges_logbook_fn(6,NOW()::TEXT);
SELECT badges_geom_fn(5,NOW()::TEXT);
SELECT badges_geom_fn(6,NOW()::TEXT);

\echo 'Check badges for user'
\echo 'Check badges for all users'
SELECT jsonb_object_keys ( a.preferences->'badges' ) FROM auth.accounts a;

\echo 'Check details from vessel_id kapla'
--SELECT get_user_settings_from_vesselid_fn('vessels.urn:mrn:imo:mmsi:123456789'::TEXT);
SELECT
json_build_object(
'boat', v.name,
Expand Down Expand Up @@ -68,6 +66,9 @@ SELECT set_config('vessel.id', :'vessel_id', false) IS NOT NULL as vessel_id;
\echo 'Process badge'
SELECT badges_moorages_fn();

\echo 'Check badges for all users'
SELECT jsonb_object_keys ( a.preferences->'badges' ) FROM auth.accounts a;

\echo 'Check details from vessel_id aava'
--SELECT get_user_settings_from_vesselid_fn('vessels.urn:mrn:imo:mmsi:787654321'::TEXT);
SELECT
Expand Down
34 changes: 33 additions & 1 deletion tests/sql/badges.sql.output
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ badges_geom_fn |
-[ RECORD 1 ]--+-
badges_geom_fn |

Check badges for user
Check badges for all users
-[ RECORD 1 ]-----+------------------
jsonb_object_keys | Helmsman
-[ RECORD 2 ]-----+------------------
Expand Down Expand Up @@ -76,6 +76,38 @@ Process badge
-[ RECORD 1 ]------+-
badges_moorages_fn |

Check badges for all users
-[ RECORD 1 ]-----+------------------
jsonb_object_keys | Helmsman
-[ RECORD 2 ]-----+------------------
jsonb_object_keys | Wake Maker
-[ RECORD 3 ]-----+------------------
jsonb_object_keys | Balearic Sea
-[ RECORD 4 ]-----+------------------
jsonb_object_keys | Stormtrooper
-[ RECORD 5 ]-----+------------------
jsonb_object_keys | Gulf of Finland
-[ RECORD 6 ]-----+------------------
jsonb_object_keys | Helmsman
-[ RECORD 7 ]-----+------------------
jsonb_object_keys | Wake Maker
-[ RECORD 8 ]-----+------------------
jsonb_object_keys | Club Alaska
-[ RECORD 9 ]-----+------------------
jsonb_object_keys | Stormtrooper
-[ RECORD 10 ]----+------------------
jsonb_object_keys | Captain Award
-[ RECORD 11 ]----+------------------
jsonb_object_keys | Caribbean Sea
-[ RECORD 12 ]----+------------------
jsonb_object_keys | Gulf of Alaska
-[ RECORD 13 ]----+------------------
jsonb_object_keys | Gulf of Finland
-[ RECORD 14 ]----+------------------
jsonb_object_keys | Navigator Award
-[ RECORD 15 ]----+------------------
jsonb_object_keys | Tropical Traveler

Check details from vessel_id aava
-[ RECORD 1 ]-+--------------------------------------------------------------------------------------------------------------
user_settings | {"boat" : "aava", "recipient" : "first_aava", "email" : "[email protected]", "pushover_key" : null}
Expand Down

0 comments on commit 65455c9

Please sign in to comment.