Skip to content

Commit 0da209d

Browse files
committed
临时抽象
1 parent 109c895 commit 0da209d

File tree

1 file changed

+6
-2
lines changed
  • crates/snm_test_utils/src

1 file changed

+6
-2
lines changed

crates/snm_test_utils/src/lib.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use std::{
22
collections::HashMap,
3-
env::{self},
3+
env::{self, current_dir},
44
fs,
55
path::PathBuf,
66
};
@@ -25,6 +25,7 @@ pub struct SnmTestContext {
2525
id: String,
2626
name: String,
2727
counter: usize,
28+
cwd: String,
2829
temp_dir: PathBuf,
2930
env_vars: HashMap<String, String>,
3031
snapshots: Vec<String>,
@@ -36,10 +37,13 @@ impl AsyncTestContext for SnmTestContext {
3637

3738
let env_vars = Self::setup_env_vars();
3839

40+
let cwd = current_dir().unwrap();
41+
3942
Self {
4043
id: uuid::Uuid::new_v4().to_string(),
4144
name: "".to_string(),
4245
counter: 0,
46+
cwd: cwd.to_string_lossy().to_string(),
4347
temp_dir: temp_dir.into_path(),
4448
env_vars,
4549
snapshots: vec![],
@@ -90,7 +94,7 @@ impl SnmTestContext {
9094
}
9195

9296
pub fn cwd(&mut self, path: &PathBuf) {
93-
self.temp_dir = path.to_owned();
97+
self.cwd = path.to_string_lossy().to_string();
9498
}
9599

96100
pub fn vars(&mut self, envs: &[(String, String)]) {

0 commit comments

Comments
 (0)