test(lesavka): isolate soft recovery state failure

This commit is contained in:
Brad Stein 2026-05-18 17:18:51 -03:00
parent 277442ef94
commit ed960b73cc

View File

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