extern crate tinyget;
mod setup;
use self::setup::*;
#[test]
fn test_headers_char_boundary_panic() {
tinyget::get("http://iheartradio.com").send().ok();
}
#[test]
#[cfg(feature = "https")]
fn test_dns_name_error() {
tinyget::get("http://virtualflorist.com").send().ok();
}
#[test]
#[cfg(feature = "https")]
fn test_https() {
assert_eq!(
get_status_code(tinyget::get("https://httpbin.org/status/418").send()),
418
);
}
#[test]
fn test_timeout_too_low() {
setup();
let result = tinyget::get(url("/slow_a")).with_timeout(1).send();
assert!(result.is_err());
}
#[test]
fn test_timeout_high_enough() {
setup();
let body = get_body(tinyget::get(url("/slow_a")).with_timeout(3).send());
assert_eq!(body, "j: Q");
}
#[test]
fn test_headers() {
setup();
let body = get_body(
tinyget::get(url("/header_pong"))
.with_header("Ping", "Qwerty")
.send(),
);
assert_eq!("Qwerty", body);
}
#[test]
fn test_custom_method() {
setup();
let body = get_body(tinyget::Request::new(url("/a")).send());
assert_eq!("j: Q", body);
}
#[test]
fn test_head() {
setup();
assert_eq!(get_status_code(tinyget::get(url("/a")).send()), 200);
}
#[test]
fn test_get() {
setup();
let body = get_body(tinyget::get(url("/a")).send());
assert_eq!(body, "j: Q");
}
#[test]
fn test_redirect_get() {
setup();
let body = get_body(tinyget::get(url("/redirect")).send());
assert_eq!(body, "j: Q");
}
#[test]
fn test_redirect_with_fragment() {
setup();
let body = get_body(tinyget::get(url("/redirect#foo")).send());
assert_eq!(body, "j: Qfoo");
}
#[test]
fn test_redirect_with_overridden_fragment() {
setup();
let body = get_body(tinyget::get(url("/redirect-baz#foo")).send());
assert_eq!(body, "j: Qbaz");
}
#[test]
fn test_infinite_redirect() {
setup();
let body = tinyget::get(url("/infiniteredirect")).send();
assert!(body.is_err());
}
#[test]
fn test_relative_redirect_get() {
setup();
let body = get_body(tinyget::get(url("/relativeredirect")).send());
assert_eq!(body, "j: Q");
}