@@ -101,22 +101,22 @@ fn compose_output_json(
101101 metadata : Option < & Metadata > ,
102102) -> serde_json:: Map < String , serde_json:: Value > {
103103 let mut output = serde_json:: Map :: new ( ) ;
104- output. insert (
105- "speed_measurements" . to_string ( ) ,
106- serde_json:: to_value ( stat_measurements) . unwrap ( ) ,
107- ) ;
108- if let Some ( latency) = latency_measurement {
109- output. insert (
110- "latency_measurement" . to_string ( ) ,
111- serde_json:: to_value ( latency) . unwrap ( ) ,
112- ) ;
113- }
114104 if let Some ( metadata) = metadata {
115105 output. insert (
116106 "metadata" . to_string ( ) ,
117107 serde_json:: to_value ( metadata) . unwrap ( ) ,
118108 ) ;
119109 }
110+ if let Some ( latency) = latency_measurement {
111+ output. insert (
112+ "latency_measurement" . to_string ( ) ,
113+ serde_json:: to_value ( latency) . unwrap ( ) ,
114+ ) ;
115+ }
116+ output. insert (
117+ "speed_measurements" . to_string ( ) ,
118+ serde_json:: to_value ( stat_measurements) . unwrap ( ) ,
119+ ) ;
120120 output
121121}
122122
@@ -379,5 +379,11 @@ mod tests {
379379
380380 assert ! ( output. get( "latency_measurement" ) . is_some( ) ) ;
381381 assert ! ( output. get( "speed_measurements" ) . is_some( ) ) ;
382+
383+ let keys: Vec < & str > = output. keys ( ) . map ( String :: as_str) . collect ( ) ;
384+ assert_eq ! (
385+ keys,
386+ vec![ "metadata" , "latency_measurement" , "speed_measurements" ]
387+ ) ;
382388 }
383389}
0 commit comments