diff --git a/tests/api/server/main/server_main_state_rpc_contract.rs b/tests/api/server/main/server_main_state_rpc_contract.rs index 0d72926..7ee1a9d 100644 --- a/tests/api/server/main/server_main_state_rpc_contract.rs +++ b/tests/api/server/main/server_main_state_rpc_contract.rs @@ -338,17 +338,19 @@ mod server_main_state_rpc { let (_dir, handler) = build_handler_for_tests(); let rt = tokio::runtime::Runtime::new().expect("runtime"); - let usb = rt - .block_on(async { handler.recover_usb_reply().await }) - .expect_err("missing fake UDC state should be reported clearly"); - assert_eq!(usb.code(), tonic::Code::FailedPrecondition); - assert!(usb.to_string().contains("could not read UDC state")); + with_var("LESAVKA_TEST_RECOVERY_STATE_ERROR", Some("1"), || { + let usb = rt + .block_on(async { handler.recover_usb_reply().await }) + .expect_err("forced fake UDC read failure should be reported clearly"); + assert_eq!(usb.code(), tonic::Code::FailedPrecondition); + assert!(usb.to_string().contains("could not read UDC state")); - let usb_rpc = rt - .block_on(async { handler.recover_usb(tonic::Request::new(Empty {})).await }) - .expect_err("RPC wrapper should surface the same missing fake UDC state"); - assert_eq!(usb_rpc.code(), tonic::Code::FailedPrecondition); - assert!(usb_rpc.to_string().contains("could not read UDC state")); + let usb_rpc = rt + .block_on(async { handler.recover_usb(tonic::Request::new(Empty {})).await }) + .expect_err("RPC wrapper should surface the same fake UDC read failure"); + assert_eq!(usb_rpc.code(), tonic::Code::FailedPrecondition); + assert!(usb_rpc.to_string().contains("could not read UDC state")); + }); with_var("LESAVKA_CAM_OUTPUT", Some("uvc"), || { let uvc = rt