Skip to content

Commit

Permalink
Add struct for CodeDeployLifecycleEvent
Browse files Browse the repository at this point in the history
CodeDeploy Hooks Lifecycle Event support

* Added struct
* Added unit test
  • Loading branch information
benbpyle committed Mar 4, 2024
1 parent e0e95e6 commit e19a583
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
21 changes: 21 additions & 0 deletions lambda-events/src/event/codedeploy/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,31 @@ pub struct CodeDeployEventDetail {
pub deployment_group: Option<String>,
}

#[derive(Debug, Clone, Deserialize, Serialize, Eq, PartialEq)]
#[serde(rename_all = "PascalCase")]
pub struct CodeDeployLifecycleEvent {
pub deployment_id: String,
pub lifecycle_event_hook_execution_id: String,
}

#[cfg(test)]
mod test {
use super::*;

#[test]
#[cfg(feature = "codedeploy")]
fn example_codedeploy_lifecycle_event() {
let data = include_bytes!("../../fixtures/example-codedeploy-lifecycle-event.json");
let parsed: CodeDeployLifecycleEvent = serde_json::from_slice(data).unwrap();

assert_eq!(parsed.deployment_id, "d-deploymentId".to_string());
assert_eq!(parsed.lifecycle_event_hook_execution_id, "eyJlbmNyeXB0ZWREYXRhIjoiY3VHU2NjdkJXUTJQUENVd2dkYUNGRVg0dWlpME9UWVdHTVhZcDRXVW5LYUVKc21EaUFPMkNLNXMwMWFrNDlYVStlbXdRb29xS3NJTUNVQ3RYRGFZSXc1VTFwUllvMDhmMzdlbDZFeDVVdjZrNFc0eU5waGh6YTRvdkNWcmVveVR6OWdERlM2SmlIYW1TZz09IiwiaXZQYXJhbWV0ZXJTcGVjIjoiTm1ZNFR6RzZxQVhHamhhLyIsIm1hdGVyaWFsU2V0U2VyaWFsIjoxfQ==".to_string());

let output: String = serde_json::to_string(&parsed).unwrap();
let reparsed: CodeDeployLifecycleEvent = serde_json::from_slice(output.as_bytes()).unwrap();
assert_eq!(parsed, reparsed);
}

#[test]
#[cfg(feature = "codedeploy")]
fn example_codedeploy_deployment_event() {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"DeploymentId": "d-deploymentId",
"LifecycleEventHookExecutionId": "eyJlbmNyeXB0ZWREYXRhIjoiY3VHU2NjdkJXUTJQUENVd2dkYUNGRVg0dWlpME9UWVdHTVhZcDRXVW5LYUVKc21EaUFPMkNLNXMwMWFrNDlYVStlbXdRb29xS3NJTUNVQ3RYRGFZSXc1VTFwUllvMDhmMzdlbDZFeDVVdjZrNFc0eU5waGh6YTRvdkNWcmVveVR6OWdERlM2SmlIYW1TZz09IiwiaXZQYXJhbWV0ZXJTcGVjIjoiTm1ZNFR6RzZxQVhHamhhLyIsIm1hdGVyaWFsU2V0U2VyaWFsIjoxfQ=="
}

0 comments on commit e19a583

Please sign in to comment.