relax PullRequestAction parsing

Unknown events are fine here, as long as it's a valid event continue and
consider it not interesting instead.

Should alleviate fixes like #496 in the future.
This commit is contained in:
Daiderd Jordan 2020-05-23 09:55:19 +02:00
parent 08717c5cf2
commit e5b9084f05
No known key found for this signature in database
GPG key ID: D02435D05B810C96
2 changed files with 16 additions and 14 deletions

View file

@ -36,21 +36,12 @@ pub enum PullRequestState {
#[derive(Serialize, Deserialize, Debug, PartialEq)] #[derive(Serialize, Deserialize, Debug, PartialEq)]
#[serde(rename_all = "snake_case")] #[serde(rename_all = "snake_case")]
pub enum PullRequestAction { pub enum PullRequestAction {
Assigned,
Unassigned,
ReviewRequested,
ReviewRequestRemoved,
Labeled,
Unlabeled,
Opened,
Edited, Edited,
Closed, Opened,
ReadyForReview,
Locked,
Unlocked,
Reopened, Reopened,
Synchronize, Synchronize,
ConvertedToDraft, #[serde(other)]
Unknown,
} }
#[derive(Serialize, Deserialize, Debug)] #[derive(Serialize, Deserialize, Debug)]
@ -73,10 +64,20 @@ mod tests {
use serde_json; use serde_json;
#[test] #[test]
fn test_parse_pr_event() { fn test_parse_changed_base() {
let data = include_str!("../../test-srcs/events/pr-changed-base.json"); let data = include_str!("../../test-srcs/events/pr-changed-base.json");
let _p: PullRequestEvent = let pr: PullRequestEvent =
serde_json::from_str(&data.to_string()).expect("Should properly deserialize"); serde_json::from_str(&data.to_string()).expect("Should properly deserialize");
assert_eq!(pr.action, PullRequestAction::Edited);
}
#[test]
fn test_parse_unknown_action() {
let data = include_str!("../../test-srcs/events/pr-converted-to-draft.json");
let pr: PullRequestEvent =
serde_json::from_str(&data.to_string()).expect("Should properly deserialize");
assert_eq!(pr.action, PullRequestAction::Unknown);
} }
} }

File diff suppressed because one or more lines are too long