Skip to content

Commit 096d254

Browse files
committed
Auto merge of #3217 - Turbo87:req, r=locks
tests: Move `req()` function to `util` module The `req()` function does not seem to be used anywhere else, so it's probably easiest to keep it in the same module as where it is used. r? `@pietroalbini`
2 parents fdba99a + 0d489e7 commit 096d254

File tree

2 files changed

+10
-11
lines changed

2 files changed

+10
-11
lines changed

src/tests/all.rs

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,7 @@ use std::{
3232
},
3333
};
3434

35-
use conduit::{header, Body};
36-
use conduit_test::MockRequest;
35+
use conduit::Body;
3736
use diesel::prelude::*;
3837
use reqwest::{blocking::Client, Proxy};
3938

@@ -178,12 +177,6 @@ fn env(var: &str) -> String {
178177
}
179178
}
180179

181-
fn req(method: conduit::Method, path: &str) -> MockRequest {
182-
let mut request = MockRequest::new(method, path);
183-
request.header(header::USER_AGENT, "conduit-test");
184-
request
185-
}
186-
187180
fn json<T>(r: &mut AppResponse) -> T
188181
where
189182
for<'de> T: serde::Deserialize<'de>,

src/tests/util.rs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -431,14 +431,20 @@ pub trait RequestHelper {
431431
}
432432
}
433433

434+
fn req(method: conduit::Method, path: &str) -> MockRequest {
435+
let mut request = MockRequest::new(method, path);
436+
request.header(header::USER_AGENT, "conduit-test");
437+
request
438+
}
439+
434440
/// A type that can generate unauthenticated requests
435441
pub struct MockAnonymousUser {
436442
app: TestApp,
437443
}
438444

439445
impl RequestHelper for MockAnonymousUser {
440446
fn request_builder(&self, method: Method, path: &str) -> MockRequest {
441-
crate::req(method, path)
447+
req(method, path)
442448
}
443449

444450
fn app(&self) -> &TestApp {
@@ -457,7 +463,7 @@ pub struct MockCookieUser {
457463

458464
impl RequestHelper for MockCookieUser {
459465
fn request_builder(&self, method: Method, path: &str) -> MockRequest {
460-
let mut request = crate::req(method, path);
466+
let mut request = req(method, path);
461467
let id = TrustedUserId(self.user.id);
462468
request.mut_extensions().insert(id);
463469
request
@@ -504,7 +510,7 @@ pub struct MockTokenUser {
504510

505511
impl RequestHelper for MockTokenUser {
506512
fn request_builder(&self, method: Method, path: &str) -> MockRequest {
507-
let mut request = crate::req(method, path);
513+
let mut request = req(method, path);
508514
request.header(header::AUTHORIZATION, &self.token.plaintext);
509515
request
510516
}

0 commit comments

Comments
 (0)