mirror of
https://github.com/cargo-bins/cargo-binstall.git
synced 2025-06-16 15:46:36 +00:00
Share remote::Client
between tests when in cargo-test
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
This commit is contained in:
parent
2feac66e14
commit
ec279cd1d5
3 changed files with 17 additions and 8 deletions
1
Cargo.lock
generated
1
Cargo.lock
generated
|
@ -354,6 +354,7 @@ version = "0.0.0"
|
|||
dependencies = [
|
||||
"binstalk-downloader",
|
||||
"compact_str",
|
||||
"once_cell",
|
||||
"percent-encoding",
|
||||
"serde",
|
||||
"serde-tuple-vec-map",
|
||||
|
|
|
@ -26,3 +26,4 @@ url = "2.3.1"
|
|||
[dev-dependencies]
|
||||
binstalk-downloader = { version = "0.11.1", path = "../binstalk-downloader" }
|
||||
tracing-subscriber = "0.3"
|
||||
once_cell = "1"
|
||||
|
|
|
@ -313,6 +313,7 @@ impl GhApiClient {
|
|||
mod test {
|
||||
use super::*;
|
||||
use compact_str::{CompactString, ToCompactString};
|
||||
use once_cell::sync::OnceCell;
|
||||
use std::{env, num::NonZeroU16, time::Duration};
|
||||
use tokio::time::sleep;
|
||||
use tracing::subscriber::set_global_default;
|
||||
|
@ -490,14 +491,20 @@ mod test {
|
|||
}
|
||||
|
||||
fn create_remote_client() -> remote::Client {
|
||||
remote::Client::new(
|
||||
concat!(env!("CARGO_PKG_NAME"), "/", env!("CARGO_PKG_VERSION")),
|
||||
None,
|
||||
NonZeroU16::new(200).unwrap(),
|
||||
1.try_into().unwrap(),
|
||||
[],
|
||||
)
|
||||
.unwrap()
|
||||
static CLIENT: OnceCell<remote::Client> = OnceCell::new();
|
||||
|
||||
CLIENT
|
||||
.get_or_init(|| {
|
||||
remote::Client::new(
|
||||
concat!(env!("CARGO_PKG_NAME"), "/", env!("CARGO_PKG_VERSION")),
|
||||
None,
|
||||
NonZeroU16::new(200).unwrap(),
|
||||
1.try_into().unwrap(),
|
||||
[],
|
||||
)
|
||||
.unwrap()
|
||||
})
|
||||
.clone()
|
||||
}
|
||||
|
||||
/// Mark this as an async fn so that you won't accidentally use it in
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue