diff --git a/Cargo.toml b/Cargo.toml index a37ceb6..0607945 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "focus" -version = "0.2.0" +version = "0.3.0" edition = "2021" license = "Apache-2.0" diff --git a/src/main.rs b/src/main.rs index 72d7c26..1a3e649 100644 --- a/src/main.rs +++ b/src/main.rs @@ -41,6 +41,7 @@ type BeamResult = TaskResult<beam_lib::RawString>; #[derive(Debug, Deserialize, Serialize, Clone)] struct Metadata { project: String, + #[serde(default)] execute: bool, } @@ -463,3 +464,22 @@ fn beam_result(task: BeamTask, measure_report: String) -> Result<BeamResult, Foc data, )) } + +mod test { + use super::*; + + const METADATA_STRING : &str = "{\"project\": \"exliquid\"}"; + + #[test] + fn test_metadata_deserialization_default() { + + let metadata: Metadata = serde_json::from_str(METADATA_STRING).unwrap_or(Metadata { + project: "default_obfuscation".to_string(), + execute: true, + }); + + assert!(!metadata.execute); + + } + +} \ No newline at end of file