Skip to content

Commit 254d8fc

Browse files
committed
fix: format ComputedFile to kebab-case to match API (#23)
1 parent 5a3dee9 commit 254d8fc

File tree

1 file changed

+24
-1
lines changed

1 file changed

+24
-1
lines changed

src/compute/computed_file.rs

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ use std::{fs, path::Path};
3131
/// }
3232
/// ```
3333
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
34-
#[serde(rename_all(deserialize = "kebab-case"))]
34+
#[serde(rename_all = "kebab-case")]
3535
pub struct ComputedFile {
3636
pub deterministic_output_path: Option<String>,
3737
pub callback_data: Option<String>,
@@ -304,6 +304,29 @@ mod tests {
304304

305305
const TEST_TASK_ID: &str = "0x123456789abcdef";
306306

307+
#[test]
308+
fn computed_file_serializes_to_kebab_case() {
309+
let file = ComputedFile {
310+
deterministic_output_path: Some("/iexec_out/result.txt".to_string()),
311+
callback_data: Some("0xabc".to_string()),
312+
task_id: Some(TEST_TASK_ID.to_string()),
313+
result_digest: Some("0xdef".to_string()),
314+
enclave_signature: Some("0xsig".to_string()),
315+
error_message: Some("err".to_string()),
316+
};
317+
let expected = r#"{
318+
"deterministic-output-path":"/iexec_out/result.txt",
319+
"callback-data":"0xabc",
320+
"task-id":"0x123456789abcdef",
321+
"result-digest":"0xdef",
322+
"enclave-signature":"0xsig",
323+
"error-message":"err"
324+
}"#;
325+
let expected_value: serde_json::Value = serde_json::from_str(expected).unwrap();
326+
let actual_value: serde_json::Value = serde_json::json!(&file);
327+
assert_eq!(actual_value, expected_value);
328+
}
329+
307330
// region read_computed_file
308331
#[test]
309332
fn read_computed_file_returns_computed_file_when_valid_input() {

0 commit comments

Comments
 (0)