Skip to content
Snippets Groups Projects
Commit 14bcb056 authored by Martin Lowe's avatar Martin Lowe :flag_ca:
Browse files

Add basic test for merge group webhook request

parent 0bb12164
No related branches found
No related tags found
1 merge request!197Iss #161 - Add merge_group webhook support to the webhook callback
Pipeline #50510 passed
......@@ -16,6 +16,7 @@ import java.util.Optional;
import org.eclipsefoundation.git.eca.api.models.GithubWebhookRequest;
import org.eclipsefoundation.git.eca.api.models.GithubWebhookRequest.Installation;
import org.eclipsefoundation.git.eca.api.models.GithubWebhookRequest.MergeGroup;
import org.eclipsefoundation.git.eca.api.models.GithubWebhookRequest.PullRequest;
import org.eclipsefoundation.git.eca.api.models.GithubWebhookRequest.PullRequestHead;
import org.eclipsefoundation.git.eca.api.models.GithubWebhookRequest.Repository;
......@@ -55,6 +56,17 @@ class GithubWebhooksResourceTest {
.run();
}
@Test
void testGHWebhook_success_mergeGroup() {
EndpointTestBuilder
.from(TestCaseHelper
.prepareTestCase(GH_WEBHOOK_BASE_URL, new String[] {}, null)
.setHeaderParams(Optional.of(Map.of(WebhookHeaders.GITHUB_DELIVERY, "id-1", WebhookHeaders.GITHUB_EVENT, "merge_group")))
.build())
.doPost(createMergeGroupWebhookBody())
.run();
}
private String createGHWebhook() {
try {
return om.writeValueAsString(GithubWebhookRequest.builder()
......@@ -75,4 +87,23 @@ class GithubWebhooksResourceTest {
throw new ApplicationException("Error converting Hook to JSON");
}
}
private String createMergeGroupWebhookBody() {
try {
return om.writeValueAsString(GithubWebhookRequest.builder()
.setInstallation(Installation.builder().setId("install-id").build())
.setMergeGroup(MergeGroup
.builder()
.setHeadSha("headsha-123")
.build())
.setRepository(Repository
.builder()
.setFullName("eclipsefdn/sample")
.setHtmlUrl("http://www.github.com/eclipsefdn/sample")
.build())
.build());
} catch (Exception e) {
throw new ApplicationException("Error converting Hook to JSON");
}
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment