Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix PullRequestReviewEvent model #305

Merged
merged 1 commit into from
Feb 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 3 additions & 14 deletions src/models/events/payload/pull_request_review.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,14 @@ pub struct PullRequestReviewEventPayload {
pub pull_request: PullRequest,
/// The review that was affected.
pub review: Review,
/// The changes to body or title if this event is of type [`PullRequestReviewEventAction::Edited`].
pub changes: Option<PullRequestReviewChanges>,
/// The repository where the event occurred.
pub repository: Repository,
/// The user that triggered the event.
pub sender: User,
}

/// The action on a pull request review this event corresponds to.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "lowercase")]
#[non_exhaustive]
pub enum PullRequestReviewEventAction {
Submitted,
Edited,
Dismissed,
Created,
}

/// The change which occurred in an event of type [`PullRequestReviewEventAction::Edited`].
Expand Down Expand Up @@ -60,9 +52,7 @@ mod test {
#[test]
fn should_deserialize_action_from_lowercase() {
let actions = vec![
(r#""submitted""#, PullRequestReviewEventAction::Submitted),
(r#""edited""#, PullRequestReviewEventAction::Edited),
(r#""dismissed""#, PullRequestReviewEventAction::Dismissed),
(r#""created""#, PullRequestReviewEventAction::Created),
];
for (action_str, action) in actions {
let deserialized = serde_json::from_str(&action_str).unwrap();
Expand Down Expand Up @@ -91,8 +81,7 @@ mod test {
let json = include_str!("../../../../tests/resources/pull_request_review_event.json");
let event: Event = serde_json::from_str(json).unwrap();
if let Some(EventPayload::PullRequestReviewEvent(payload)) = event.payload {
assert_eq!(payload.action, PullRequestReviewEventAction::Submitted);
assert_eq!(payload.pull_request.id.0, 279147437);
assert_eq!(payload.pull_request.id.0, 1237933052);
} else {
panic!("unexpected event payload encountered: {:#?}", event.payload);
}
Expand Down
Loading