Skip to content

Commit 4c86fad

Browse files
committed
fix: update tests to be compatible with Windows
1 parent 70dd879 commit 4c86fad

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

src/env.rs

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -305,9 +305,19 @@ mod tests {
305305
#[test]
306306
fn expand_path_splits_on_default_separator() {
307307
let args = env_args_expand_path();
308-
let mut json_value = json!({ "PATH": "/usr/bin:/bin:/usr/local/bin" });
308+
let (input, expected) = if cfg!(windows) {
309+
(
310+
json!({ "PATH": "C:\\Windows;C:\\Windows\\System32;C:\\Windows\\System32\\Wbem" }),
311+
json!({ "PATH": ["C:\\Windows", "C:\\Windows\\System32", "C:\\Windows\\System32\\Wbem"] }),
312+
)
313+
} else {
314+
(
315+
json!({ "PATH": "/usr/bin:/bin:/usr/local/bin" }),
316+
json!({ "PATH": ["/usr/bin", "/bin", "/usr/local/bin"] }),
317+
)
318+
};
319+
let mut json_value = input;
309320
args.expand_path_variable(&mut json_value);
310-
let expected = json!({ "PATH": ["/usr/bin", "/bin", "/usr/local/bin"] });
311321
assert_eq!(json_value, expected);
312322
}
313323

@@ -330,15 +340,15 @@ mod tests {
330340

331341
#[test]
332342
fn expand_path_is_case_insensitive() {
333-
let args = env_args_expand_path();
343+
let args = env_args_expand_path_with_separator(":");
334344
let mut json_value = json!({ "path": "/usr/bin:/bin" });
335345
args.expand_path_variable(&mut json_value);
336346
assert_eq!(json_value, json!({ "path": ["/usr/bin", "/bin"] }));
337347
}
338348

339349
#[test]
340350
fn expand_path_mixed_case_is_case_insensitive() {
341-
let args = env_args_expand_path();
351+
let args = env_args_expand_path_with_separator(":");
342352
let mut json_value = json!({ "Path": "/usr/bin:/bin" });
343353
args.expand_path_variable(&mut json_value);
344354
assert_eq!(json_value, json!({ "Path": ["/usr/bin", "/bin"] }));

0 commit comments

Comments
 (0)