File tree Expand file tree Collapse file tree 2 files changed +25
-1
lines changed
tests/RobotFramework/tests/tedge_flows Expand file tree Collapse file tree 2 files changed +25
-1
lines changed Original file line number Diff line number Diff line change 1+ export function onMessage ( message ) {
2+ let payload = JSON . parse ( message . payload )
3+ let timestamp = message . timestamp
4+ let tzOffset = timestamp . getTimezoneOffset ( ) * 60000 ;
5+
6+ payload . time = timestamp . toString ( ) ;
7+ payload . utc = timestamp . toISOString ( ) ;
8+ payload . local = ( new Date ( timestamp . getTime ( ) - tzOffset ) ) . toISOString ( ) . slice ( 0 , - 1 ) ;
9+
10+ return {
11+ topic : message . topic ,
12+ payload : JSON . stringify ( payload )
13+ }
14+ }
Original file line number Diff line number Diff line change @@ -10,13 +10,23 @@ Test Tags theme:tedge_flows
1010
1111*** Test Cases ***
1212Add missing timestamps
13- ${transformed_msg } Execute Command tedge flows test --processing-time "2025-06-27 11:31:02" te/device/main///m/ '{}'
13+ ${transformed_msg } Execute Command
14+ ... tedge flows test --processing-time "2025-06-27 11:31:02" te/device/main///m/ '{}'
1415 Should Contain ${transformed_msg } item="time":"2025-06-27T11:31:02.000Z"
1516
1617Convert timestamps to ISO
1718 ${transformed_msg } Execute Command tedge flows test te/device/main///m/ '{"time": 1751023862.000}'
1819 Should Contain ${transformed_msg } item="time":"2025-06-27T11:31:02.000Z"
1920
21+ Convert message timestamps to local time
22+ Execute Command ln -sf /usr/share/zoneinfo/Australia/Brisbane /etc/localtime
23+ ${transformed_msg } Execute Command
24+ ... tedge flows test --flow get-localtime.js --processing-time "2025-11-19T11:31:02" t {}
25+ Should Contain ${transformed_msg } item="time":"Wed Nov 19 2025 21:31:02 GMT+1000"
26+ Should Contain ${transformed_msg } item="utc":"2025-11-19T11:31:02.000Z"
27+ Should Contain ${transformed_msg } item="local":"2025-11-19T21:31:02.000
28+ [Teardown] Execute Command ln -sf /usr/share/zoneinfo/Etc/UTC /etc/localtime
29+
2030Extract measurement type from topic
2131 ${transformed_msg } Execute Command
2232 ... tedge flows test te/device/main///m/environment '{"temperature": 258}'
You can’t perform that action at this time.
0 commit comments