product-os-request 0.0.55

Product OS : Request provides a fully featured HTTP request library combining elements of reqwest and hyper for async requests with a series of helper methods to allow for easier usage depending upon your needs for one-time or repeat usage.
Documentation
// Test suite for ProductOSRequestError
#![cfg(any(feature = "request", feature = "request_std"))]

use product_os_request::ProductOSRequestError;

#[test]
fn test_error_display_with_message() {
    let error = ProductOSRequestError::Error(String::from("Connection failed"));
    let display_str = format!("{}", error);
    assert_eq!(display_str, "Connection failed");
}

#[allow(deprecated)]
#[test]
fn test_error_display_none() {
    let error = ProductOSRequestError::None;
    let display_str = format!("{}", error);
    assert_eq!(display_str, "No error");
}

#[test]
fn test_error_debug() {
    let error = ProductOSRequestError::Error(String::from("Test error"));
    let debug_str = format!("{:?}", error);
    assert!(debug_str.contains("Error"));
    assert!(debug_str.contains("Test error"));
}

#[allow(deprecated)]
#[test]
fn test_error_none_debug() {
    let error = ProductOSRequestError::None;
    let debug_str = format!("{:?}", error);
    assert_eq!(debug_str, "None");
}

#[test]
fn test_error_creation() {
    let msg = String::from("Custom error message");
    let error = ProductOSRequestError::Error(msg.clone());

    match error {
        ProductOSRequestError::Error(m) => assert_eq!(m, msg),
        _ => panic!("Expected Error variant"),
    }
}

#[test]
fn test_error_empty_message() {
    let error = ProductOSRequestError::Error(String::new());
    let display_str = format!("{}", error);
    assert_eq!(display_str, "");
}

#[test]
fn test_error_multiline_message() {
    let msg = String::from("Error occurred:\nLine 1\nLine 2");
    let error = ProductOSRequestError::Error(msg.clone());
    let display_str = format!("{}", error);
    assert_eq!(display_str, msg);
}

#[test]
fn test_error_invalid_uri_variant() {
    let error = ProductOSRequestError::InvalidUri(String::from("not a url"));
    let display_str = format!("{}", error);
    assert!(display_str.contains("Invalid URI"));
    assert!(display_str.contains("not a url"));
}

#[test]
fn test_error_timeout_variant() {
    let error = ProductOSRequestError::Timeout(String::from("5s elapsed"));
    let display_str = format!("{}", error);
    assert!(display_str.contains("timeout"));
    assert!(display_str.contains("5s elapsed"));
}

#[test]
fn test_error_tls_variant() {
    let error = ProductOSRequestError::Tls(String::from("certificate expired"));
    let display_str = format!("{}", error);
    assert!(display_str.contains("TLS"));
    assert!(display_str.contains("certificate expired"));
}

#[test]
fn test_error_body_variant() {
    let error = ProductOSRequestError::BodyError(String::from("invalid utf-8"));
    let display_str = format!("{}", error);
    assert!(display_str.contains("Body error"));
    assert!(display_str.contains("invalid utf-8"));
}