Skip to content

Commit

Permalink
feat: derive Deserialize, Clone, PartialEq, Eq for MetadataPrelude
Browse files Browse the repository at this point in the history
  • Loading branch information
DiscreteTom committed Jan 6, 2025
1 parent f69280e commit f674d87
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion lambda-runtime/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ impl<T> LambdaEvent<T> {
}

/// Metadata prelude for a stream response.
#[derive(Debug, Default, Serialize)]
#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq, Eq)]
#[serde(rename_all = "camelCase")]
pub struct MetadataPrelude {
#[serde(with = "http_serde::status_code")]
Expand Down Expand Up @@ -478,4 +478,22 @@ mod test {

let _ = invoke_request_id(&headers);
}

#[test]
fn serde_metadata_prelude() {
let metadata_prelude = MetadataPrelude {
status_code: StatusCode::OK,
headers: {
let mut headers = HeaderMap::new();
headers.insert("key", "val".parse().unwrap());
headers
},
cookies: vec!["cookie".to_string()],
};

let serialized = serde_json::to_string(&metadata_prelude).unwrap();
let deserialized: MetadataPrelude = serde_json::from_str(&serialized).unwrap();

assert_eq!(metadata_prelude, deserialized);
}
}

0 comments on commit f674d87

Please sign in to comment.