Skip to content

Commit e04f59f

Browse files
committed
fix: allow null executable in CLI test assertions for Conda envs without Python
1 parent fa82ba0 commit e04f59f

File tree

1 file changed

+15
-7
lines changed

1 file changed

+15
-7
lines changed

crates/pet/tests/cli_test.rs

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -43,19 +43,25 @@ fn find_json_output_is_valid() {
4343
"expected 'environments' array in output"
4444
);
4545

46-
// Each environment should have at minimum an executable and kind
46+
// Each environment should have at minimum a kind.
47+
// Executable may be null for environments without Python installed (e.g. Conda
48+
// envs created without specifying python as a dependency).
4749
let environments = json["environments"].as_array().unwrap();
4850
assert!(
4951
!environments.is_empty(),
5052
"expected at least one environment to be discovered"
5153
);
54+
let mut has_executable = false;
5255
for env in environments {
53-
assert!(
54-
env["executable"].is_string(),
55-
"environment missing 'executable': {env}"
56-
);
5756
assert!(env["kind"].is_string(), "environment missing 'kind': {env}");
57+
if env["executable"].is_string() {
58+
has_executable = true;
59+
}
5860
}
61+
assert!(
62+
has_executable,
63+
"expected at least one environment with an executable"
64+
);
5965
}
6066

6167
/// Test 2: `resolve --json` returns a resolved environment with a version.
@@ -192,9 +198,11 @@ fn find_workspace_scoping() {
192198

193199
let scoped_envs = json["environments"].as_array().unwrap();
194200
for env in scoped_envs {
201+
// executable may be null for environments without Python installed.
202+
// No has_executable check: workspace-scoped finds may return zero environments.
195203
assert!(
196-
env["executable"].is_string(),
197-
"workspace environment missing 'executable': {env}"
204+
env["kind"].is_string(),
205+
"workspace environment missing 'kind': {env}"
198206
);
199207
}
200208

0 commit comments

Comments
 (0)