Skip to content

Commit 0d3de00

Browse files
committed
Allow use of chrono::Utc::now in the tests
Clock cannot be used because of a circular dependency
1 parent 351457f commit 0d3de00

File tree

1 file changed

+20
-5
lines changed

1 file changed

+20
-5
lines changed

crates/data-model/src/oauth2/authorization_grant.rs

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -301,9 +301,12 @@ mod tests {
301301
#[allow(clippy::disallowed_methods)]
302302
let mut rng = thread_rng();
303303

304+
#[allow(clippy::disallowed_methods)]
305+
let now = Utc::now();
306+
304307
let grant = AuthorizationGrant {
305308
login_hint: None,
306-
..AuthorizationGrant::sample(Utc::now(), &mut rng)
309+
..AuthorizationGrant::sample(now, &mut rng)
307310
};
308311

309312
let hint = grant.parse_login_hint(&get_homeserver());
@@ -316,9 +319,12 @@ mod tests {
316319
#[allow(clippy::disallowed_methods)]
317320
let mut rng = thread_rng();
318321

322+
#[allow(clippy::disallowed_methods)]
323+
let now = Utc::now();
324+
319325
let grant = AuthorizationGrant {
320326
login_hint: Some(String::from("mxid:@example-user:example.com")),
321-
..AuthorizationGrant::sample(Utc::now(), &mut rng)
327+
..AuthorizationGrant::sample(now, &mut rng)
322328
};
323329

324330
let hint = grant.parse_login_hint(&get_homeserver());
@@ -331,9 +337,12 @@ mod tests {
331337
#[allow(clippy::disallowed_methods)]
332338
let mut rng = thread_rng();
333339

340+
#[allow(clippy::disallowed_methods)]
341+
let now = Utc::now();
342+
334343
let grant = AuthorizationGrant {
335344
login_hint: Some(String::from("example-user")),
336-
..AuthorizationGrant::sample(Utc::now(), &mut rng)
345+
..AuthorizationGrant::sample(now, &mut rng)
337346
};
338347

339348
let hint = grant.parse_login_hint(&get_homeserver());
@@ -346,9 +355,12 @@ mod tests {
346355
#[allow(clippy::disallowed_methods)]
347356
let mut rng = thread_rng();
348357

358+
#[allow(clippy::disallowed_methods)]
359+
let now = Utc::now();
360+
349361
let grant = AuthorizationGrant {
350362
login_hint: Some(String::from("mxid:@example-user:matrix.org")),
351-
..AuthorizationGrant::sample(Utc::now(), &mut rng)
363+
..AuthorizationGrant::sample(now, &mut rng)
352364
};
353365

354366
let hint = grant.parse_login_hint(&get_homeserver());
@@ -361,9 +373,12 @@ mod tests {
361373
#[allow(clippy::disallowed_methods)]
362374
let mut rng = thread_rng();
363375

376+
#[allow(clippy::disallowed_methods)]
377+
let now = Utc::now();
378+
364379
let grant = AuthorizationGrant {
365380
login_hint: Some(String::from("something:anything")),
366-
..AuthorizationGrant::sample(Utc::now(), &mut rng)
381+
..AuthorizationGrant::sample(now, &mut rng)
367382
};
368383

369384
let hint = grant.parse_login_hint(&get_homeserver());

0 commit comments

Comments
 (0)