Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rewrite some http unit tests with fetch. #14131

Merged
merged 4 commits into from Nov 8, 2016
Merged
Changes from 1 commit
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

Next

Rewrite test_load_when_request_is_not_get_or_head_and_there_is_no_bod…

…y_content_length_should_be_set_to_0.
  • Loading branch information
Ms2ger committed Nov 8, 2016
commit 06567e1d5b48b214bb9cf8e5b8cd1574942b9d81
@@ -436,24 +436,24 @@ fn test_check_default_headers_loaded_in_every_request() {

#[test]
fn test_load_when_request_is_not_get_or_head_and_there_is_no_body_content_length_should_be_set_to_0() {
let url = Url::parse("http://mozilla.com").unwrap();

let http_state = HttpState::new();
let ui_provider = TestProvider::new();

let mut load_data = LoadData::new(LoadContext::Browsing, url.clone(), &HttpTest);
load_data.data = None;
load_data.method = Method::Post;
let handler = move |request: HyperRequest, _: HyperResponse| {
assert_eq!(request.headers.get::<ContentLength>(), Some(&ContentLength(0)));
};
let (mut server, url) = make_server(handler);

let mut content_length = Headers::new();
content_length.set(ContentLength(0));
let request = Request::from_init(RequestInit {
url: url.clone(),
method: Method::Post,
body: None,
destination: Destination::Document,
origin: url.clone(),
pipeline_id: Some(TEST_PIPELINE_ID),
.. RequestInit::default()
});
let response = fetch_sync(request, None);
assert!(response.status.unwrap().is_success());

let _ = load(
&load_data, &ui_provider, &http_state,
None, &AssertMustIncludeHeadersRequestFactory {
expected_headers: content_length,
body: <[_]>::to_vec(&[])
}, DEFAULT_USER_AGENT.into(), &CancellationListener::new(None), None);
let _ = server.close();
}

#[test]
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.