mirror of
https://github.com/xbgmsharp/postgsail.git
synced 2025-09-17 03:07:47 +00:00
Add metadata SQL test
This commit is contained in:
32
tests/sql/metadata.sql
Normal file
32
tests/sql/metadata.sql
Normal file
@@ -0,0 +1,32 @@
|
||||
---------------------------------------------------------------------------
|
||||
-- Listing
|
||||
--
|
||||
|
||||
-- List current database
|
||||
select current_database();
|
||||
|
||||
-- connect to the DB
|
||||
\c signalk
|
||||
|
||||
-- output display format
|
||||
\x on
|
||||
|
||||
SELECT v.vessel_id as "vessel_id" FROM auth.vessels v WHERE v.owner_email = 'demo+kapla@openplotter.cloud' \gset
|
||||
--\echo :"vessel_id"
|
||||
SELECT set_config('vessel.id', :'vessel_id', false) IS NOT NULL as vessel_id;
|
||||
|
||||
--SELECT * FROM api.metadata m;
|
||||
\echo 'api.metadata details'
|
||||
SELECT m.id, m.name, m.mmsi, m.length, m.beam, m.height, m.ship_type, m.plugin_version, m.signalk_version, m.time IS NOT NULL AS time, m.active, configuration, available_keys FROM api.metadata AS m ORDER BY m.name ASC;
|
||||
|
||||
\echo 'api.metadata get configuration'
|
||||
select configuration from api.metadata WHERE vessel_id = current_setting('vessel.id', false);
|
||||
|
||||
\echo 'api.metadata update configuration'
|
||||
UPDATE api.metadata SET configuration = '{ "depthKey": "environment.depth.belowTransducer" }' WHERE vessel_id = current_setting('vessel.id', false);
|
||||
|
||||
\echo 'api.metadata get configuration with new value'
|
||||
select configuration->'depthKey' AS depthKey, configuration->'update_at' IS NOT NULL AS update_at from api.metadata WHERE vessel_id = current_setting('vessel.id', false);
|
||||
|
||||
\echo 'api.metadata get configuration base on update_at value'
|
||||
select configuration->'depthKey' AS depthKey, configuration->'update_at' IS NOT NULL AS update_at from api.metadata WHERE vessel_id = current_setting('vessel.id', false) AND configuration->>'update_at' = to_char(NOW(), 'YYYY-MM-DD"T"HH24:MI:SS"Z"');
|
56
tests/sql/metadata.sql.output
Normal file
56
tests/sql/metadata.sql.output
Normal file
@@ -0,0 +1,56 @@
|
||||
current_database
|
||||
------------------
|
||||
signalk
|
||||
(1 row)
|
||||
|
||||
You are now connected to database "signalk" as user "username".
|
||||
Expanded display is on.
|
||||
-[ RECORD 1 ]
|
||||
vessel_id | t
|
||||
|
||||
api.metadata details
|
||||
-[ RECORD 1 ]---+----------------
|
||||
id | 2
|
||||
name | aava
|
||||
mmsi | 787654321
|
||||
length | 12
|
||||
beam | 10
|
||||
height | 24
|
||||
ship_type | 37
|
||||
plugin_version | 1.0.2
|
||||
signalk_version | 1.20.0
|
||||
time | t
|
||||
active | t
|
||||
configuration |
|
||||
available_keys | []
|
||||
-[ RECORD 2 ]---+----------------
|
||||
id | 1
|
||||
name | kapla
|
||||
mmsi | 123456789
|
||||
length | 12
|
||||
beam | 10
|
||||
height | 24
|
||||
ship_type | 36
|
||||
plugin_version | 0.0.1
|
||||
signalk_version | signalk_version
|
||||
time | t
|
||||
active | t
|
||||
configuration |
|
||||
available_keys |
|
||||
|
||||
api.metadata get configuration
|
||||
-[ RECORD 1 ]-+-
|
||||
configuration |
|
||||
|
||||
api.metadata update configuration
|
||||
UPDATE 1
|
||||
api.metadata get configuration with new value
|
||||
-[ RECORD 1 ]----------------------------------
|
||||
depthkey | "environment.depth.belowTransducer"
|
||||
update_at | t
|
||||
|
||||
api.metadata get configuration base on update_at value
|
||||
-[ RECORD 1 ]----------------------------------
|
||||
depthkey | "environment.depth.belowTransducer"
|
||||
update_at | t
|
||||
|
Reference in New Issue
Block a user