Skip to content

Commit 3dc45ec

Browse files
committed
tests/util: Change MockTokenUser::token to be optional
1 parent 619f968 commit 3dc45ec

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/tests/util.rs

+4-3
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,7 @@ impl MockCookieUser {
335335

336336
MockTokenUser {
337337
app: self.app.clone(),
338-
token,
338+
token: Some(token),
339339
plaintext: plaintext.expose_secret().into(),
340340
}
341341
}
@@ -344,7 +344,7 @@ impl MockCookieUser {
344344
/// A type that can generate token authenticated requests
345345
pub struct MockTokenUser {
346346
app: TestApp,
347-
token: ApiToken,
347+
token: Option<ApiToken>,
348348
plaintext: String,
349349
}
350350

@@ -363,7 +363,8 @@ impl RequestHelper for MockTokenUser {
363363
impl MockTokenUser {
364364
/// Returns a reference to the database `ApiToken` model
365365
pub fn as_model(&self) -> &ApiToken {
366-
&self.token
366+
const ERROR: &str = "Original `ApiToken` was not set on this `MockTokenUser` instance";
367+
self.token.as_ref().expect(ERROR)
367368
}
368369

369370
pub fn plaintext(&self) -> &str {

0 commit comments

Comments
 (0)