Skip to content

Commit c6e98e0

Browse files
committed
RUST-1663: Remove unnecessary top level function by cloning twice
1 parent 3464d03 commit c6e98e0

File tree

1 file changed

+20
-12
lines changed

1 file changed

+20
-12
lines changed

src/test/spec/oidc.rs

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,6 @@ use crate::{
88
};
99
use std::sync::{Arc, Mutex};
1010

11-
// simple_cb is a simple callback that increments the passed atomic integer and returns a static IdpServerResponse
12-
async fn simple_cb(call_count: Arc<Mutex<u32>>) -> crate::error::Result<oidc::IdpServerResponse> {
13-
*call_count.lock().unwrap() += 1;
14-
Ok(oidc::IdpServerResponse {
15-
access_token: tokio::fs::read_to_string("/tmp/tokens/test_user1").await?,
16-
expires: None,
17-
refresh_token: None,
18-
})
19-
}
20-
2111
// Machine Callback tests
2212
// Prose test 1.1 Single Principal Implicit Username
2313
#[tokio::test]
@@ -38,7 +28,16 @@ async fn machine_single_principal_implicit_username() -> anyhow::Result<()> {
3828
opts.credential = Credential::builder()
3929
.mechanism(AuthMechanism::MongoDbOidc)
4030
.oidc_callback(oidc::Callback::machine(move |_| {
41-
{ simple_cb(cb_call_count.clone()) }.boxed()
31+
let call_count = cb_call_count.clone();
32+
async move {
33+
*call_count.lock().unwrap() += 1;
34+
Ok(oidc::IdpServerResponse {
35+
access_token: tokio::fs::read_to_string("/tmp/tokens/test_user1").await?,
36+
expires: None,
37+
refresh_token: None,
38+
})
39+
}
40+
.boxed()
4241
}))
4342
.build()
4443
.into();
@@ -80,7 +79,16 @@ async fn human_single_principal_implicit_username() -> anyhow::Result<()> {
8079
opts.credential = Credential::builder()
8180
.mechanism(AuthMechanism::MongoDbOidc)
8281
.oidc_callback(oidc::Callback::human(move |_| {
83-
{ simple_cb(cb_call_count.clone()) }.boxed()
82+
let call_count = cb_call_count.clone();
83+
async move {
84+
*call_count.lock().unwrap() += 1;
85+
Ok(oidc::IdpServerResponse {
86+
access_token: tokio::fs::read_to_string("/tmp/tokens/test_user1").await?,
87+
expires: None,
88+
refresh_token: None,
89+
})
90+
}
91+
.boxed()
8492
}))
8593
.build()
8694
.into();

0 commit comments

Comments
 (0)