style(src-tauri): cargo fmt
Pure mechanical rustfmt reformat (default config, no rustfmt.toml).
This commit is contained in:
@@ -18,7 +18,12 @@ pub struct Reply {
|
||||
}
|
||||
|
||||
pub fn reply(status: u16, body: Value) -> Reply {
|
||||
Reply { status, headers: vec![], body: body.to_string(), delay_ms: 0 }
|
||||
Reply {
|
||||
status,
|
||||
headers: vec![],
|
||||
body: body.to_string(),
|
||||
delay_ms: 0,
|
||||
}
|
||||
}
|
||||
|
||||
pub struct Mock {
|
||||
@@ -33,7 +38,12 @@ pub async fn serve(script: Vec<Reply>) -> Mock {
|
||||
let script = Arc::new(script);
|
||||
serve_fn(move |i, _| {
|
||||
let r = &script[i.min(script.len() - 1)];
|
||||
Reply { status: r.status, headers: r.headers.clone(), body: r.body.clone(), delay_ms: r.delay_ms }
|
||||
Reply {
|
||||
status: r.status,
|
||||
headers: r.headers.clone(),
|
||||
body: r.body.clone(),
|
||||
delay_ms: r.delay_ms,
|
||||
}
|
||||
})
|
||||
.await
|
||||
}
|
||||
@@ -48,7 +58,9 @@ pub async fn serve_fn(handler: impl Fn(usize, &str) -> Reply + Send + Sync + 'st
|
||||
let handler = Arc::new(handler);
|
||||
tokio::spawn(async move {
|
||||
loop {
|
||||
let Ok((mut sock, _)) = listener.accept().await else { return };
|
||||
let Ok((mut sock, _)) = listener.accept().await else {
|
||||
return;
|
||||
};
|
||||
let (h, r, handler) = (h.clone(), r.clone(), handler.clone());
|
||||
tokio::spawn(async move {
|
||||
let mut buf = Vec::new();
|
||||
@@ -97,7 +109,11 @@ pub async fn serve_fn(handler: impl Fn(usize, &str) -> Reply + Send + Sync + 'st
|
||||
});
|
||||
}
|
||||
});
|
||||
Mock { base: format!("http://127.0.0.1:{port}"), hits, requests }
|
||||
Mock {
|
||||
base: format!("http://127.0.0.1:{port}"),
|
||||
hits,
|
||||
requests,
|
||||
}
|
||||
}
|
||||
|
||||
/// Short timeouts and near-zero backoff so retry tests run in milliseconds.
|
||||
@@ -113,5 +129,12 @@ pub fn fast_opts() -> ClientOptions {
|
||||
}
|
||||
|
||||
pub fn client(mock: &Mock) -> ErpClient {
|
||||
ErpClient::new(&mock.base, "thekey", &Secret::new("thesecret"), "", fast_opts()).unwrap()
|
||||
ErpClient::new(
|
||||
&mock.base,
|
||||
"thekey",
|
||||
&Secret::new("thesecret"),
|
||||
"",
|
||||
fast_opts(),
|
||||
)
|
||||
.unwrap()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user