//! Extra integration coverage for server main HID startup branches. //! //! Scope: include `server/src/main.rs` and exercise successful handler startup //! with synthetic HID endpoints. //! Targets: `server/src/main.rs`. //! Why: the main contract file is near the 500 LOC cap, so additional branch //! coverage lives here. #[allow(warnings)] mod server_main_binary_extra { include!(env!("LESAVKA_SERVER_MAIN_SRC")); use serial_test::serial; use temp_env::with_var; use tempfile::tempdir; #[test] #[serial] fn handler_new_and_reopen_hid_succeed_with_override_paths() { let dir = tempdir().expect("tempdir"); std::fs::write(dir.path().join("hidg0"), "").expect("create hidg0"); std::fs::write(dir.path().join("hidg1"), "").expect("create hidg1"); let hid_dir = dir.path().to_string_lossy().to_string(); with_var("LESAVKA_HID_DIR", Some(hid_dir), || { with_var("LESAVKA_ALLOW_GADGET_CYCLE", None::<&str>, || { let rt = tokio::runtime::Runtime::new().expect("runtime"); rt.block_on(async { let handler = Handler::new(UsbGadget::new("lesavka")) .await .expect("handler startup"); handler.reopen_hid().await.expect("reopen hid"); }); }); }); } #[test] #[serial] fn handler_new_with_cycle_enabled_can_still_open_override_paths() { let dir = tempdir().expect("tempdir"); std::fs::write(dir.path().join("hidg0"), "").expect("create hidg0"); std::fs::write(dir.path().join("hidg1"), "").expect("create hidg1"); let hid_dir = dir.path().to_string_lossy().to_string(); with_var("LESAVKA_HID_DIR", Some(hid_dir), || { with_var("LESAVKA_ALLOW_GADGET_CYCLE", Some("1"), || { let rt = tokio::runtime::Runtime::new().expect("runtime"); rt.block_on(async { let _handler = Handler::new(UsbGadget::new("lesavka")) .await .expect("handler startup with cycle enabled"); }); }); }); } }