Skip to content

Commit 622642c

Browse files
authored
fix: optional env (#133)
* fix: optional env * actual change * fix: made all things optional * fix: forgot test attribute
1 parent 0ade018 commit 622642c

File tree

4 files changed

+54
-0
lines changed

4 files changed

+54
-0
lines changed

crates/pixi-build-cmake/src/config.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,22 @@ use serde::Deserialize;
55
#[serde(rename_all = "kebab-case")]
66
pub struct CMakeBackendConfig {
77
/// Extra args for CMake invocation
8+
#[serde(default)]
89
pub extra_args: Vec<String>,
910
/// Environment Variables
11+
#[serde(default)]
1012
pub env: IndexMap<String, String>,
1113
}
14+
15+
#[cfg(test)]
16+
mod tests {
17+
use serde_json::json;
18+
19+
use super::CMakeBackendConfig;
20+
21+
#[test]
22+
fn test_ensure_deseralize_from_empty() {
23+
let json_data = json!({});
24+
serde_json::from_value::<CMakeBackendConfig>(json_data).unwrap();
25+
}
26+
}

crates/pixi-build-python/src/config.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ pub struct PythonBackendConfig {
1111
pub noarch: Option<bool>,
1212

1313
/// Environment Variables
14+
#[serde(default)]
1415
pub env: IndexMap<String, String>,
1516
}
1617

@@ -20,3 +21,15 @@ impl PythonBackendConfig {
2021
self.noarch.map_or(true, identity)
2122
}
2223
}
24+
25+
#[cfg(test)]
26+
mod tests {
27+
use super::PythonBackendConfig;
28+
use serde_json::json;
29+
30+
#[test]
31+
fn test_ensure_deseralize_from_empty() {
32+
let json_data = json!({});
33+
serde_json::from_value::<PythonBackendConfig>(json_data).unwrap();
34+
}
35+
}

crates/pixi-build-rattler-build/src/config.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,15 @@ use std::path::PathBuf;
66
pub struct RattlerBuildBackendConfig {
77
pub debug_dir: Option<PathBuf>,
88
}
9+
10+
#[cfg(test)]
11+
mod tests {
12+
use super::RattlerBuildBackendConfig;
13+
use serde_json::json;
14+
15+
#[test]
16+
fn test_ensure_deseralize_from_empty() {
17+
let json_data = json!({});
18+
serde_json::from_value::<RattlerBuildBackendConfig>(json_data).unwrap();
19+
}
20+
}

crates/pixi-build-rust/src/config.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,22 @@ use serde::Deserialize;
66
#[serde(rename_all = "kebab-case")]
77
pub struct RustBackendConfig {
88
/// Extra args to pass for cargo
9+
#[serde(default)]
910
pub extra_args: Vec<String>,
1011

1112
/// Environment Variables
13+
#[serde(default)]
1214
pub env: IndexMap<String, String>,
1315
}
16+
17+
#[cfg(test)]
18+
mod tests {
19+
use super::RustBackendConfig;
20+
use serde_json::json;
21+
22+
#[test]
23+
fn test_ensure_deseralize_from_empty() {
24+
let json_data = json!({});
25+
serde_json::from_value::<RustBackendConfig>(json_data).unwrap();
26+
}
27+
}

0 commit comments

Comments
 (0)