@@ -247,58 +247,23 @@ configs:
247247 assert ! ( result. is_ok( ) ) ;
248248
249249 let values_file = temp_dir. path ( ) . join ( INFRA_AGENT_VALUES ) ;
250-
251- // Read the contents of the values.yaml file
252250 let values_content = fs:: read_to_string ( & values_file) . unwrap ( ) ;
253251
254- // Parse the YAML content
255252 let parsed_values: serde_yaml:: Value = serde_yaml:: from_str ( & values_content) . unwrap ( ) ;
256253
257- // Assertions to verify the contents of the values.yaml file
258- if let serde_yaml:: Value :: Mapping ( map) = parsed_values {
259- if let Some ( serde_yaml:: Value :: Mapping ( config_agent_map) ) =
260- map. get ( serde_yaml:: Value :: String ( "config_agent" . to_string ( ) ) )
261- {
262- assert_eq ! (
263- config_agent_map. get( serde_yaml:: Value :: String ( "staging" . to_string( ) ) ) ,
264- Some ( & serde_yaml:: Value :: Bool ( true ) )
265- ) ;
266- assert_eq ! (
267- config_agent_map. get( serde_yaml:: Value :: String ( "extra_config" . to_string( ) ) ) ,
268- Some ( & serde_yaml:: Value :: Bool ( true ) )
269- ) ;
270- assert_eq ! (
271- config_agent_map. get( serde_yaml:: Value :: String (
272- "status_server_enabled" . to_string( )
273- ) ) ,
274- Some ( & serde_yaml:: Value :: Bool ( true ) )
275- ) ;
276- assert_eq ! (
277- config_agent_map. get( serde_yaml:: Value :: String (
278- "enable_process_metrics" . to_string( )
279- ) ) ,
280- Some ( & serde_yaml:: Value :: Bool ( true ) )
281- ) ;
282- assert_eq ! (
283- config_agent_map. get( serde_yaml:: Value :: String ( "license_key" . to_string( ) ) ) ,
284- Some ( & serde_yaml:: Value :: String (
285- "{{NEW_RELIC_LICENSE_KEY}}" . to_string( )
286- ) )
287- ) ;
288- assert_eq ! (
289- config_agent_map
290- . get( serde_yaml:: Value :: String ( "status_server_port" . to_string( ) ) ) ,
291- Some ( & serde_yaml:: Value :: Number ( serde_yaml:: Number :: from( 18003 ) ) )
292- ) ;
293- // proxy is modified
294- assert_eq ! (
295- config_agent_map. get( serde_yaml:: Value :: String ( "proxy" . to_string( ) ) ) ,
296- Some ( & serde_yaml:: Value :: String ( new_proxy) )
297- ) ;
298- }
299- } else {
300- panic ! ( "Expected a YAML mapping" ) ;
301- }
254+ let expected = r"#
255+ config_agent:
256+ extra_config: true
257+ status_server_enabled: true
258+ enable_process_metrics: true
259+ license_key: '{{NEW_RELIC_LICENSE_KEY}}'
260+ status_server_port: 18003
261+ staging: true
262+ proxy: https://new-proxy.com
263+ #" ;
264+ let expected_values: serde_yaml:: Value = serde_yaml:: from_str ( expected) . unwrap ( ) ;
265+ assert_eq ! ( parsed_values, expected_values) ;
266+
302267 }
303268
304269 #[ cfg( target_family = "unix" ) ] //TODO This should be removed when Windows support is added
@@ -330,37 +295,14 @@ configs:
330295 // Parse the YAML content
331296 let parsed_values: serde_yaml:: Value = serde_yaml:: from_str ( & values_content) . unwrap ( ) ;
332297
333- // Assertions to verify the contents of the values.yaml file
334- if let serde_yaml:: Value :: Mapping ( map) = parsed_values {
335- if let Some ( serde_yaml:: Value :: Mapping ( config_agent_map) ) =
336- map. get ( serde_yaml:: Value :: String ( "config_agent" . to_string ( ) ) )
337- {
338- assert_eq ! (
339- config_agent_map. get( serde_yaml:: Value :: String (
340- "status_server_enabled" . to_string( )
341- ) ) ,
342- Some ( & serde_yaml:: Value :: Bool ( true ) )
343- ) ;
344- assert_eq ! (
345- config_agent_map. get( serde_yaml:: Value :: String (
346- "enable_process_metrics" . to_string( )
347- ) ) ,
348- Some ( & serde_yaml:: Value :: Bool ( true ) )
349- ) ;
350- assert_eq ! (
351- config_agent_map. get( serde_yaml:: Value :: String ( "license_key" . to_string( ) ) ) ,
352- Some ( & serde_yaml:: Value :: String (
353- "{{NEW_RELIC_LICENSE_KEY}}" . to_string( )
354- ) )
355- ) ;
356- assert_eq ! (
357- config_agent_map
358- . get( serde_yaml:: Value :: String ( "status_server_port" . to_string( ) ) ) ,
359- Some ( & serde_yaml:: Value :: Number ( serde_yaml:: Number :: from( 18003 ) ) )
360- ) ;
361- }
362- } else {
363- panic ! ( "Expected a YAML mapping" ) ;
364- }
298+ let expected = r"#
299+ config_agent:
300+ status_server_enabled: true
301+ enable_process_metrics: true
302+ license_key: '{{NEW_RELIC_LICENSE_KEY}}'
303+ status_server_port: 18003
304+ #" ;
305+ let expected_values: serde_yaml:: Value = serde_yaml:: from_str ( expected) . unwrap ( ) ;
306+ assert_eq ! ( parsed_values, expected_values) ;
365307 }
366308}
0 commit comments