// Include-based coverage for microphone startup cleanup paths.
//
// Scope: include `client/src/input/microphone.rs` and exercise startup
// failures without requiring a live microphone.
// Targets: `client/src/input/microphone.rs`.
// Why: startup failures should move the pipeline back to NULL before the
// capture object returns an error.

#[allow(warnings)]
mod live_capture_clock {
    include!(concat!(
        env!("CARGO_MANIFEST_DIR"),
        "/tests/helpers/support/live_capture_clock_shim.rs"
    ));
}

#[allow(warnings)]
mod input {
    pub mod audio_codec {
        pub use lesavka_client::input::audio_codec::*;
    }
}

#[allow(warnings)]
mod microphone_startup_contract {
    include!(env!("LESAVKA_CLIENT_MICROPHONE_SRC"));

    use serial_test::serial;
    use temp_env::with_var;

    #[test]
    #[cfg(coverage)]
    #[serial]
    fn startup_failure_cleans_up_pipeline_state() {
        gst::init().ok();
        with_var("LESAVKA_MIC_SOURCE", None::<&str>, || {
            with_var(
                "LESAVKA_MIC_TEST_SOURCE_DESC",
                Some("filesrc location=/definitely-missing-lesavka-mic.raw"),
                || {
                    let result = MicrophoneCapture::new();
                    assert!(result.is_err(), "missing filesrc should fail startup");
                },
            );
        });
    }
}
