From d1b07673b8837f5f5dd97466a617853b576a865e Mon Sep 17 00:00:00 2001 From: Josh Matthews Date: Tue, 12 Apr 2016 18:23:18 -0400 Subject: Convert AssertMustNotIncludeHeadersRequestFactory. --- tests/unit/net/http_loader.rs | 45 ++++++++----------------------------------- 1 file changed, 8 insertions(+), 37 deletions(-) (limited to 'tests/unit/net/http_loader.rs') diff --git a/tests/unit/net/http_loader.rs b/tests/unit/net/http_loader.rs index 4dfd29c9b25..8ac53cebc9f 100644 --- a/tests/unit/net/http_loader.rs +++ b/tests/unit/net/http_loader.rs @@ -251,50 +251,21 @@ fn assert_cookie_for_domain(cookie_jar: Arc>, domain: &str } } -struct AssertRequestMustNotIncludeHeaders { - headers_not_expected: Vec, - request_headers: Headers, - t: ResponseType -} - -impl AssertRequestMustNotIncludeHeaders { - fn new(t: ResponseType, headers_not_expected: Vec) -> Self { - assert!(headers_not_expected.len() != 0); - AssertRequestMustNotIncludeHeaders { - headers_not_expected: headers_not_expected, - request_headers: Headers::new(), t: t } - } -} - -impl HttpRequest for AssertRequestMustNotIncludeHeaders { - type R = MockResponse; - - fn headers_mut(&mut self) -> &mut Headers { &mut self.request_headers } - - fn send(self, _: &Option>) -> Result { - for header in &self.headers_not_expected { - assert!(self.request_headers.get_raw(header).is_none()); - } - - response_for_request_type(self.t) - } -} - struct AssertMustNotIncludeHeadersRequestFactory { headers_not_expected: Vec, body: Vec } impl HttpRequestFactory for AssertMustNotIncludeHeadersRequestFactory { - type R = AssertRequestMustNotIncludeHeaders; + type R = MockRequest; - fn create(&self, _: Url, _: Method) -> Result { - Ok( - AssertRequestMustNotIncludeHeaders::new( - ResponseType::Text(self.body.clone()), - self.headers_not_expected.clone() - ) - ) + fn create_with_headers(&self, _: Url, _: Method, headers: Headers) -> Result { + assert!(self.headers_not_expected.len() != 0); + for header in &self.headers_not_expected { + assert!(headers.get_raw(header).is_none()); + } + + Ok(MockRequest::new(ResponseType::Text(self.body.clone()))) } } -- cgit v1.2.3