mirror of
https://github.com/cargo-bins/cargo-binstall.git
synced 2025-06-16 23:56:37 +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 = [
|
dependencies = [
|
||||||
"binstalk-downloader",
|
"binstalk-downloader",
|
||||||
"compact_str",
|
"compact_str",
|
||||||
|
"once_cell",
|
||||||
"percent-encoding",
|
"percent-encoding",
|
||||||
"serde",
|
"serde",
|
||||||
"serde-tuple-vec-map",
|
"serde-tuple-vec-map",
|
||||||
|
|
|
@ -26,3 +26,4 @@ url = "2.3.1"
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
binstalk-downloader = { version = "0.11.1", path = "../binstalk-downloader" }
|
binstalk-downloader = { version = "0.11.1", path = "../binstalk-downloader" }
|
||||||
tracing-subscriber = "0.3"
|
tracing-subscriber = "0.3"
|
||||||
|
once_cell = "1"
|
||||||
|
|
|
@ -313,6 +313,7 @@ impl GhApiClient {
|
||||||
mod test {
|
mod test {
|
||||||
use super::*;
|
use super::*;
|
||||||
use compact_str::{CompactString, ToCompactString};
|
use compact_str::{CompactString, ToCompactString};
|
||||||
|
use once_cell::sync::OnceCell;
|
||||||
use std::{env, num::NonZeroU16, time::Duration};
|
use std::{env, num::NonZeroU16, time::Duration};
|
||||||
use tokio::time::sleep;
|
use tokio::time::sleep;
|
||||||
use tracing::subscriber::set_global_default;
|
use tracing::subscriber::set_global_default;
|
||||||
|
@ -490,6 +491,10 @@ mod test {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn create_remote_client() -> remote::Client {
|
fn create_remote_client() -> remote::Client {
|
||||||
|
static CLIENT: OnceCell<remote::Client> = OnceCell::new();
|
||||||
|
|
||||||
|
CLIENT
|
||||||
|
.get_or_init(|| {
|
||||||
remote::Client::new(
|
remote::Client::new(
|
||||||
concat!(env!("CARGO_PKG_NAME"), "/", env!("CARGO_PKG_VERSION")),
|
concat!(env!("CARGO_PKG_NAME"), "/", env!("CARGO_PKG_VERSION")),
|
||||||
None,
|
None,
|
||||||
|
@ -498,6 +503,8 @@ mod test {
|
||||||
[],
|
[],
|
||||||
)
|
)
|
||||||
.unwrap()
|
.unwrap()
|
||||||
|
})
|
||||||
|
.clone()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Mark this as an async fn so that you won't accidentally use it in
|
/// 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