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 Protocol and Proxy types
#![cfg(any(feature = "request", feature = "request_std"))]

use product_os_request::{Protocol, Proxy};

#[test]
fn test_protocol_clone() {
    let protocol = Protocol::HTTPS;
    let cloned = protocol.clone();
    assert_eq!(protocol, cloned);
}

#[test]
fn test_protocol_debug() {
    let protocol = Protocol::HTTP;
    let debug_str = format!("{:?}", protocol);
    assert_eq!(debug_str, "HTTP");
}

#[test]
fn test_protocol_equality() {
    assert_eq!(Protocol::HTTP, Protocol::HTTP);
    assert_ne!(Protocol::HTTP, Protocol::HTTPS);
    assert_eq!(Protocol::SOCKS5, Protocol::SOCKS5);
    assert_eq!(Protocol::ALL, Protocol::ALL);
}

#[test]
fn test_all_protocols() {
    let protocols = vec![
        Protocol::SOCKS5,
        Protocol::HTTP,
        Protocol::HTTPS,
        Protocol::ALL,
    ];

    for protocol in protocols {
        let _ = protocol.clone();
        let _ = format!("{:?}", protocol);
        assert_eq!(protocol, protocol);
    }
}

#[test]
fn test_proxy_construction() {
    let proxy = Proxy {
        protocol: Protocol::HTTP,
        address: String::from("127.0.0.1:8080"),
    };

    assert_eq!(proxy.protocol, Protocol::HTTP);
    assert_eq!(proxy.address, "127.0.0.1:8080");
}

#[test]
fn test_proxy_clone() {
    let proxy = Proxy {
        protocol: Protocol::HTTPS,
        address: String::from("proxy.example.com:443"),
    };

    let cloned = proxy.clone();
    assert_eq!(proxy.protocol, cloned.protocol);
    assert_eq!(proxy.address, cloned.address);
}

#[test]
fn test_proxy_debug() {
    let proxy = Proxy {
        protocol: Protocol::SOCKS5,
        address: String::from("socks.example.com:1080"),
    };

    let debug_str = format!("{:?}", proxy);
    assert!(debug_str.contains("SOCKS5"));
    assert!(debug_str.contains("socks.example.com:1080"));
}

#[test]
fn test_proxy_equality() {
    let proxy1 = Proxy {
        protocol: Protocol::HTTP,
        address: String::from("proxy1.com:8080"),
    };

    let proxy2 = Proxy {
        protocol: Protocol::HTTP,
        address: String::from("proxy1.com:8080"),
    };

    let proxy3 = Proxy {
        protocol: Protocol::HTTPS,
        address: String::from("proxy1.com:8080"),
    };

    assert_eq!(proxy1, proxy2);
    assert_ne!(proxy1, proxy3);
}

#[test]
fn test_proxy_with_all_protocols() {
    let protocols = vec![
        Protocol::SOCKS5,
        Protocol::HTTP,
        Protocol::HTTPS,
        Protocol::ALL,
    ];

    for protocol in protocols {
        let proxy = Proxy {
            protocol: protocol.clone(),
            address: String::from("test.proxy.com:8080"),
        };

        assert_eq!(proxy.protocol, protocol);
    }
}