@@ -1427,7 +1427,7 @@ async fn test_fleet_agents_list() {
14271427 let mut s = mockito:: Server :: new_async ( ) . await ;
14281428 let cfg = test_config ( & s. url ( ) ) ;
14291429 mock_all ( & mut s, r#"{"data": []}"# ) . await ;
1430- let _ = crate :: commands:: fleet:: agents_list ( & cfg, None ) . await ;
1430+ let _ = crate :: commands:: fleet:: agents_list ( & cfg, None , None ) . await ;
14311431 cleanup_env ( ) ;
14321432}
14331433#[ tokio:: test]
@@ -2054,6 +2054,61 @@ async fn test_apm_services_list() {
20542054 crate :: commands:: apm:: services_list ( & cfg, "prod" . into ( ) , "1h" . into ( ) , "now" . into ( ) ) . await ;
20552055 cleanup_env ( ) ;
20562056}
2057+ #[ tokio:: test]
2058+ async fn test_apm_troubleshooting_list ( ) {
2059+ let _lock = lock_env ( ) ;
2060+ let mut server = mockito:: Server :: new_async ( ) . await ;
2061+ let cfg = test_config ( & server. url ( ) ) ;
2062+
2063+ let mock = server
2064+ . mock ( "GET" , "/api/unstable/apm/instrumentation-errors" )
2065+ . match_query ( mockito:: Matcher :: UrlEncoded (
2066+ "hostname" . into ( ) ,
2067+ "my-host" . into ( ) ,
2068+ ) )
2069+ . with_status ( 200 )
2070+ . with_header ( "content-type" , "application/json" )
2071+ . with_body ( r#"{"data": []}"# )
2072+ . create_async ( )
2073+ . await ;
2074+
2075+ let result = crate :: commands:: apm:: troubleshooting_list ( & cfg, "my-host" . into ( ) , None ) . await ;
2076+ assert ! (
2077+ result. is_ok( ) ,
2078+ "troubleshooting list failed: {:?}" ,
2079+ result. err( )
2080+ ) ;
2081+ mock. assert_async ( ) . await ;
2082+ cleanup_env ( ) ;
2083+ }
2084+ #[ tokio:: test]
2085+ async fn test_apm_troubleshooting_list_with_timeframe ( ) {
2086+ let _lock = lock_env ( ) ;
2087+ let mut server = mockito:: Server :: new_async ( ) . await ;
2088+ let cfg = test_config ( & server. url ( ) ) ;
2089+
2090+ let mock = server
2091+ . mock ( "GET" , "/api/unstable/apm/instrumentation-errors" )
2092+ . match_query ( mockito:: Matcher :: AllOf ( vec ! [
2093+ mockito:: Matcher :: UrlEncoded ( "hostname" . into( ) , "my-host" . into( ) ) ,
2094+ mockito:: Matcher :: UrlEncoded ( "timeframe" . into( ) , "4h" . into( ) ) ,
2095+ ] ) )
2096+ . with_status ( 200 )
2097+ . with_header ( "content-type" , "application/json" )
2098+ . with_body ( r#"{"data": []}"# )
2099+ . create_async ( )
2100+ . await ;
2101+
2102+ let result =
2103+ crate :: commands:: apm:: troubleshooting_list ( & cfg, "my-host" . into ( ) , Some ( "4h" . into ( ) ) ) . await ;
2104+ assert ! (
2105+ result. is_ok( ) ,
2106+ "troubleshooting list with timeframe failed: {:?}" ,
2107+ result. err( )
2108+ ) ;
2109+ mock. assert_async ( ) . await ;
2110+ cleanup_env ( ) ;
2111+ }
20572112
20582113// -------------------------------------------------------------------------
20592114// Read-only mode
0 commit comments