Skip to content

Commit

Permalink
test: use mock environment variables in maa-dirs tests
Browse files Browse the repository at this point in the history
Change environment variables is not thread-safe, use a mock struct to avoid conflict.
Because rust support ZST, so in normal case, there should be no overhead.
  • Loading branch information
wangl-cc committed Jan 18, 2025
1 parent 76b4538 commit 444d1f8
Show file tree
Hide file tree
Showing 4 changed files with 330 additions and 259 deletions.
3 changes: 2 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 1 addition & 3 deletions crates/maa-cli/src/installer/maa_cli.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use std::{collections::BTreeMap, time::Duration};

use anyhow::{anyhow, Context, Result};
use maa_dirs::MAA_CLI_EXE;
use semver::Version;
use serde::Deserialize;
use tokio::runtime::Runtime;
Expand All @@ -15,9 +16,6 @@ use crate::{
dirs::{self, Ensure},
};

const MAA_CLI_NAME: &str = "maa";
const MAA_CLI_EXE: &str = constcat::concat!(MAA_CLI_NAME, std::env::consts::EXE_SUFFIX);

pub fn update(args: &CommonArgs) -> Result<()> {
let config = CLI_CONFIG.cli_config().with_args(args);

Expand Down
5 changes: 4 additions & 1 deletion crates/maa-dirs/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "maa-dirs"
version = "0.1.1"
version = "0.1.2"
edition = "2021"
license.workspace = true
homepage.workspace = true
Expand All @@ -11,3 +11,6 @@ constcat = { workspace = true }
directories = { workspace = true }
dunce = { workspace = true }
log = { workspace = true }

[dev-dependencies]
tempfile.workspace = true
Loading

0 comments on commit 444d1f8

Please sign in to comment.