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:
parent
08717c5cf2
commit
e5b9084f05
|
@ -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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
1
ofborg/test-srcs/events/pr-converted-to-draft.json
Normal file
1
ofborg/test-srcs/events/pr-converted-to-draft.json
Normal file
File diff suppressed because one or more lines are too long
Loading…
Reference in a new issue