pub fn write_junit_report(
    file_path: PathBuf,
    hurl_results: Vec<HurlResult>,
) -> Result<(), CliError> {
    let mut doc = if file_path.exists() {
        let parser = Parser::default();
        parser
            .parse_string(
                std::fs::read_to_string(file_path.clone()).map_err(|e| CliError {
                    message: format!("Failed to read file {:?}: {:?}", file_path, e),
                })?,
            )
            .map_err(|e| CliError {
                message: format!("Failed to parse file {:?}: {:?}", file_path, e),
            })?
    } else {
        initialise_junit_report()?
    };
    let mut testsuites = doc
        .get_root_element()
        .ok_or_else(|| CliError::from("Missing testsuites element"))?;

    create_junit_report(&mut doc, &mut testsuites, hurl_results)?;

    if !file_path.exists() {
        let _ = match std::fs::File::create(&file_path) {
            Err(why) => {
                return Err(CliError {
                    message: format!("Issue writing to {}: {:?}", file_path.display(), why),
                });
            }
            Ok(file) => file,
        };
    } else {
    }

    write_junit_report_with(file_path, &doc)?;
    Ok(())
}
/// Generate a JUnix XML report and write it to the specified `PathBuf`
Generate a JUnix XML report and write it to the specified `PathBuf`
Generate a JUnix XML report and write it to the specified ` PathBuf `
pub fn write_junit_report(
    file_path: PathBuf,
    hurl_results: Vec<HurlResult>,
) -> Result<(), CliError> {
    let mut doc = if file_path.exists() {
        let parser = Parser::default();
        parser
            .parse_string(
                std::fs::read_to_string(file_path.clone()).map_err(|e| CliError {
                    message: format!("Failed to read file {:?}: {:?}", file_path, e),
                })?,
            )
            .map_err(|e| CliError {
                message: format!("Failed to parse file {:?}: {:?}", file_path, e),
            })?
    } else {
        initialise_junit_report()?
    };
    let mut testsuites = doc
        .get_root_element()
        .ok_or_else(|| CliError::from("Missing testsuites element"))?;
    create_junit_report(&mut doc, &mut testsuites, hurl_results)?;
    if !file_path.exists() {
        let _ = match std::fs::File::create(&file_path) {
            Err(why) => {
                return Err(CliError {
                    message: format!("Issue writing to {}: {:?}", file_path.display(), why),
                });
            }
            Ok(file) => file,
        };
    } else {
    }
    write_junit_report_with(file_path, &doc)?;
    Ok(())
}
pub fn write_junit_report ( file_path : PathBuf , hurl_results : Vec < HurlResult > , ) -> Result < ( ) , CliError > { let mut doc = if file_path . exists ( ) { let parser = Parser :: default ( ) ; parser . parse_string ( std :: fs :: read_to_string ( file_path . clone ( ) ) . map_err ( | e | CliError { message : format ! ( " " file_path e ) , } ) ? , ) . map_err ( | e | CliError { message : format ! ( " " file_path e ) , } ) ? } else { initialise_junit_report ( ) ? } ; let mut testsuites = doc . get_root_element ( ) . ok_or_else ( | | CliError :: from ( " " ) ) ? ; create_junit_report ( & mut doc , & mut testsuites , hurl_results ) ? ; if ! file_path . exists ( ) { let _ = match std :: fs :: File :: create ( & file_path ) { Err ( why ) => { return Err ( CliError { message : format ! ( " " file_path display ( ) why ) , } ) ; } Ok ( file ) => file , } ; } else { } write_junit_report_with ( file_path , & doc ) ? ; Ok ( ( ) ) }
Generate a JUnix XML report and write it to the specified `PathBuf`
Generate a JUnix XML report and write it to the specified ` PathBuf `
file_path
PathBuf
hurl_results
Vec<HurlResult>
file_path
PathBuf
hurl_results
Vec<HurlResult>