Skip to content

Commit 03996f3

Browse files
vohoanglong0107Vo Hoang Long
authored andcommitted
test: webhook event
1 parent 5fdce04 commit 03996f3

File tree

3 files changed

+1177
-0
lines changed

3 files changed

+1177
-0
lines changed

src/github/webhook.rs

Lines changed: 133 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -490,6 +490,139 @@ mod tests {
490490
);
491491
}
492492

493+
#[tokio::test]
494+
async fn pull_request_edited() {
495+
insta::assert_debug_snapshot!(
496+
check_webhook("webhook/pull-request-edited.json", "pull_request").await,
497+
@r###"
498+
Ok(
499+
GitHubWebhook(
500+
Repository(
501+
PullRequestEdited(
502+
PullRequestEdited {
503+
repository: GithubRepoName {
504+
owner: "vohoanglong0107",
505+
name: "test-bors",
506+
},
507+
pull_request: PullRequest {
508+
number: PullRequestNumber(
509+
1,
510+
),
511+
head_label: "vohoanglong0107:test",
512+
head: Branch {
513+
name: "test",
514+
sha: CommitSha(
515+
"bedf96270622ff19b4711dd7df3f19f4be1cba93",
516+
),
517+
},
518+
base: Branch {
519+
name: "testest",
520+
sha: CommitSha(
521+
"1f1ee58e3067678d3752dd5f6f3abb936325fbb8",
522+
),
523+
},
524+
title: "Create test.txt",
525+
message: "",
526+
author: GithubUser {
527+
id: UserId(
528+
78085736,
529+
),
530+
username: "vohoanglong0107",
531+
html_url: Url {
532+
scheme: "https",
533+
cannot_be_a_base: false,
534+
username: "",
535+
password: None,
536+
host: Some(
537+
Domain(
538+
"github.com",
539+
),
540+
),
541+
port: None,
542+
path: "/vohoanglong0107",
543+
query: None,
544+
fragment: None,
545+
},
546+
},
547+
},
548+
from_base_sha: Some(
549+
CommitSha(
550+
"1f1ee58e3067678d3752dd5f6f3abb936325fbb8",
551+
),
552+
),
553+
},
554+
),
555+
),
556+
),
557+
)
558+
"###
559+
);
560+
}
561+
562+
#[tokio::test]
563+
async fn pull_request_synchronized() {
564+
insta::assert_debug_snapshot!(
565+
check_webhook("webhook/pull-request-synchronize.json", "pull_request").await,
566+
@r###"
567+
Ok(
568+
GitHubWebhook(
569+
Repository(
570+
PullRequestCommitPushed(
571+
PullRequestPushed {
572+
repository: GithubRepoName {
573+
owner: "vohoanglong0107",
574+
name: "test-bors",
575+
},
576+
pull_request: PullRequest {
577+
number: PullRequestNumber(
578+
1,
579+
),
580+
head_label: "vohoanglong0107:test",
581+
head: Branch {
582+
name: "test",
583+
sha: CommitSha(
584+
"bedf96270622ff19b4711dd7df3f19f4be1cba93",
585+
),
586+
},
587+
base: Branch {
588+
name: "main",
589+
sha: CommitSha(
590+
"1f1ee58e3067678d3752dd5f6f3abb936325fbb8",
591+
),
592+
},
593+
title: "Create test.txt",
594+
message: "",
595+
author: GithubUser {
596+
id: UserId(
597+
78085736,
598+
),
599+
username: "vohoanglong0107",
600+
html_url: Url {
601+
scheme: "https",
602+
cannot_be_a_base: false,
603+
username: "",
604+
password: None,
605+
host: Some(
606+
Domain(
607+
"github.com",
608+
),
609+
),
610+
port: None,
611+
path: "/vohoanglong0107",
612+
query: None,
613+
fragment: None,
614+
},
615+
},
616+
},
617+
},
618+
),
619+
),
620+
),
621+
)
622+
"###
623+
);
624+
}
625+
493626
#[tokio::test]
494627
async fn pull_request_review() {
495628
insta::assert_debug_snapshot!(

0 commit comments

Comments
 (0)