diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index db6172d..e503137 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -26,9 +26,15 @@ jobs: run: dotnet publish -c Release --output /home/runner/work/Testably.Server/Testably.Server/publish/ Source/Testably.Server/Testably.Server.csproj - name: Shutdown webpage shell: pwsh + continue-on-error: true run: | - Invoke-WebRequest -Uri http://testably.com/lifetime/quit -Method POST - Start-Sleep -Seconds 5 + try { + (Invoke-WebRequest -Uri https://testably.org/lifetime/quit -Method POST -ErrorAction Stop).BaseResponse + Write-Information "The server was shutdown" + Start-Sleep -Seconds 5 + } catch [System.Net.WebException] { + Write-Warning "An exception was caught: $($_.Exception.Message)" + } - name: Upload ftp uses: sebastianpopp/ftp-action@releases/v2 with: diff --git a/Source/Testably.Server/Controllers/PullRequestStatusCheckController.cs b/Source/Testably.Server/Controllers/PullRequestStatusCheckController.cs index a55abbb..f7afaea 100644 --- a/Source/Testably.Server/Controllers/PullRequestStatusCheckController.cs +++ b/Source/Testably.Server/Controllers/PullRequestStatusCheckController.cs @@ -51,16 +51,17 @@ public PullRequestStatusCheckController( [HttpPost] public async Task OnPullRequestChanged( - [FromBody] WebhookModel pullRequestModel, + [FromBody] PullRequestWebhookModel pullRequestModel, CancellationToken cancellationToken) { - if (pullRequestModel.Event != "pull_request") + if (!HttpContext.Request.Headers.TryGetValue("x-github-event", out var value) || + value != "pull_request") { return Ok("Ignore all events except 'pull_request'."); } - if (pullRequestModel.Payload.Repository.Private || - pullRequestModel.Payload.Repository.Owner.Login != RepositoryOwner) + if (pullRequestModel.Repository.Private || + pullRequestModel.Repository.Owner.Login != RepositoryOwner) { return BadRequest($"Only public repositories from '{RepositoryOwner}' are supported!"); } @@ -72,9 +73,9 @@ public async Task OnPullRequestChanged( client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", bearerToken); - var owner = pullRequestModel.Payload.Repository.Owner.Login; - var repo = pullRequestModel.Payload.Repository.Name; - var prNumber = pullRequestModel.Payload.Number; + var owner = pullRequestModel.Repository.Owner.Login; + var repo = pullRequestModel.Repository.Name; + var prNumber = pullRequestModel.Number; var requestUri = $"https://api.github.com/repos/{owner}/{repo}/pulls/{prNumber}"; _logger.LogInformation("Try reading '{RequestUri}'", requestUri); var response = await client diff --git a/Tests/Testably.Server.Tests/WebhookTests.cs b/Tests/Testably.Server.Tests/WebhookTests.cs index 78c0859..00c4a07 100644 --- a/Tests/Testably.Server.Tests/WebhookTests.cs +++ b/Tests/Testably.Server.Tests/WebhookTests.cs @@ -7,80 +7,81 @@ namespace Testably.Server.Tests; public class WebhookTests { - [Theory] - [InlineData("feat: foo", "success")] - [InlineData("invalid", "failure")] - public async Task HappyCase_ShouldSucceed(string title, string status) - { - var webhookPayload = - """ - {"event":"pull_request","payload":{"action":"edited","number":1,"pull_request":{"url":"https://api.github.com/repos/Testably/Testably.Server/pulls/1","id":1798848450,"node_id":"PR_kwDOLne9u85rOD_C","html_url":"https://github.com/Testably/Testably.Server/pull/1","diff_url":"https://github.com/Testably/Testably.Server/pull/1.diff","patch_url":"https://github.com/Testably/Testably.Server/pull/1.patch","issue_url":"https://api.github.com/repos/Testably/Testably.Server/issues/1","number":1,"state":"open","locked":false,"title":"feat: create a PR2","user":{"login":"vbreuss","id":3438234,"node_id":"MDQ6VXNlcjM0MzgyMzQ=","avatar_url":"https://avatars.githubusercontent.com/u/3438234?v=4","gravatar_id":"","url":"https://api.github.com/users/vbreuss","html_url":"https://github.com/vbreuss","followers_url":"https://api.github.com/users/vbreuss/followers","following_url":"https://api.github.com/users/vbreuss/following{/other_user}","gists_url":"https://api.github.com/users/vbreuss/gists{/gist_id}","starred_url":"https://api.github.com/users/vbreuss/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vbreuss/subscriptions","organizations_url":"https://api.github.com/users/vbreuss/orgs","repos_url":"https://api.github.com/users/vbreuss/repos","events_url":"https://api.github.com/users/vbreuss/events{/privacy}","received_events_url":"https://api.github.com/users/vbreuss/received_events","type":"User","site_admin":false},"body":null,"created_at":"2024-03-30T09:40:30Z","updated_at":"2024-03-30T10:19:35Z","closed_at":null,"merged_at":null,"merge_commit_sha":"c58bf0ce4d7ed8a0c5efef05eb593e0ef5f2ec9e","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"draft":false,"commits_url":"https://api.github.com/repos/Testably/Testably.Server/pulls/1/commits","review_comments_url":"https://api.github.com/repos/Testably/Testably.Server/pulls/1/comments","review_comment_url":"https://api.github.com/repos/Testably/Testably.Server/pulls/comments{/number}","comments_url":"https://api.github.com/repos/Testably/Testably.Server/issues/1/comments","statuses_url":"https://api.github.com/repos/Testably/Testably.Server/statuses/21fca141f27cec38edf14c405c7413b3a3f6c6ed","head":{"label":"Testably:topic/add-initial-project","ref":"topic/add-initial-project","sha":"21fca141f27cec38edf14c405c7413b3a3f6c6ed","user":{"login":"Testably","id":113782592,"node_id":"O_kgDOBsgvQA","avatar_url":"https://avatars.githubusercontent.com/u/113782592?v=4","gravatar_id":"","url":"https://api.github.com/users/Testably","html_url":"https://github.com/Testably","followers_url":"https://api.github.com/users/Testably/followers","following_url":"https://api.github.com/users/Testably/following{/other_user}","gists_url":"https://api.github.com/users/Testably/gists{/gist_id}","starred_url":"https://api.github.com/users/Testably/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Testably/subscriptions","organizations_url":"https://api.github.com/users/Testably/orgs","repos_url":"https://api.github.com/users/Testably/repos","events_url":"https://api.github.com/users/Testably/events{/privacy}","received_events_url":"https://api.github.com/users/Testably/received_events","type":"Organization","site_admin":false},"repo":{"id":779599291,"node_id":"R_kgDOLne9uw","name":"Testably.Server","full_name":"Testably/Testably.Server","private":false,"owner":{"login":"Testably","id":113782592,"node_id":"O_kgDOBsgvQA","avatar_url":"https://avatars.githubusercontent.com/u/113782592?v=4","gravatar_id":"","url":"https://api.github.com/users/Testably","html_url":"https://github.com/Testably","followers_url":"https://api.github.com/users/Testably/followers","following_url":"https://api.github.com/users/Testably/following{/other_user}","gists_url":"https://api.github.com/users/Testably/gists{/gist_id}","starred_url":"https://api.github.com/users/Testably/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Testably/subscriptions","organizations_url":"https://api.github.com/users/Testably/orgs","repos_url":"https://api.github.com/users/Testably/repos","events_url":"https://api.github.com/users/Testably/events{/privacy}","received_events_url":"https://api.github.com/users/Testably/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/Testably/Testably.Server","description":"The server for the Testably projects.","fork":false,"url":"https://api.github.com/repos/Testably/Testably.Server","forks_url":"https://api.github.com/repos/Testably/Testably.Server/forks","keys_url":"https://api.github.com/repos/Testably/Testably.Server/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Testably/Testably.Server/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Testably/Testably.Server/teams","hooks_url":"https://api.github.com/repos/Testably/Testably.Server/hooks","issue_events_url":"https://api.github.com/repos/Testably/Testably.Server/issues/events{/number}","events_url":"https://api.github.com/repos/Testably/Testably.Server/events","assignees_url":"https://api.github.com/repos/Testably/Testably.Server/assignees{/user}","branches_url":"https://api.github.com/repos/Testably/Testably.Server/branches{/branch}","tags_url":"https://api.github.com/repos/Testably/Testably.Server/tags","blobs_url":"https://api.github.com/repos/Testably/Testably.Server/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Testably/Testably.Server/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Testably/Testably.Server/git/refs{/sha}","trees_url":"https://api.github.com/repos/Testably/Testably.Server/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Testably/Testably.Server/statuses/{sha}","languages_url":"https://api.github.com/repos/Testably/Testably.Server/languages","stargazers_url":"https://api.github.com/repos/Testably/Testably.Server/stargazers","contributors_url":"https://api.github.com/repos/Testably/Testably.Server/contributors","subscribers_url":"https://api.github.com/repos/Testably/Testably.Server/subscribers","subscription_url":"https://api.github.com/repos/Testably/Testably.Server/subscription","commits_url":"https://api.github.com/repos/Testably/Testably.Server/commits{/sha}","git_commits_url":"https://api.github.com/repos/Testably/Testably.Server/git/commits{/sha}","comments_url":"https://api.github.com/repos/Testably/Testably.Server/comments{/number}","issue_comment_url":"https://api.github.com/repos/Testably/Testably.Server/issues/comments{/number}","contents_url":"https://api.github.com/repos/Testably/Testably.Server/contents/{+path}","compare_url":"https://api.github.com/repos/Testably/Testably.Server/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Testably/Testably.Server/merges","archive_url":"https://api.github.com/repos/Testably/Testably.Server/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Testably/Testably.Server/downloads","issues_url":"https://api.github.com/repos/Testably/Testably.Server/issues{/number}","pulls_url":"https://api.github.com/repos/Testably/Testably.Server/pulls{/number}","milestones_url":"https://api.github.com/repos/Testably/Testably.Server/milestones{/number}","notifications_url":"https://api.github.com/repos/Testably/Testably.Server/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Testably/Testably.Server/labels{/name}","releases_url":"https://api.github.com/repos/Testably/Testably.Server/releases{/id}","deployments_url":"https://api.github.com/repos/Testably/Testably.Server/deployments","created_at":"2024-03-30T09:08:11Z","updated_at":"2024-03-30T10:16:47Z","pushed_at":"2024-03-30T09:40:31Z","git_url":"git://github.com/Testably/Testably.Server.git","ssh_url":"git@github.com:Testably/Testably.Server.git","clone_url":"https://github.com/Testably/Testably.Server.git","svn_url":"https://github.com/Testably/Testably.Server","homepage":"","size":17,"stargazers_count":0,"watchers_count":0,"language":null,"has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"has_discussions":false,"forks_count":0,"mirror_url":null,"archived":false,"disabled":false,"open_issues_count":1,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit","node_id":"MDc6TGljZW5zZTEz"},"allow_forking":true,"is_template":false,"web_commit_signoff_required":false,"topics":[],"visibility":"public","forks":0,"open_issues":1,"watchers":0,"default_branch":"main","allow_squash_merge":true,"allow_merge_commit":true,"allow_rebase_merge":true,"allow_auto_merge":false,"delete_branch_on_merge":false,"allow_update_branch":false,"use_squash_pr_title_as_default":false,"squash_merge_commit_message":"COMMIT_MESSAGES","squash_merge_commit_title":"COMMIT_OR_PR_TITLE","merge_commit_message":"PR_TITLE","merge_commit_title":"MERGE_MESSAGE"}},"base":{"label":"Testably:main","ref":"main","sha":"2a08a4ac7915f896c25838fab56c8711e6dd2220","user":{"login":"Testably","id":113782592,"node_id":"O_kgDOBsgvQA","avatar_url":"https://avatars.githubusercontent.com/u/113782592?v=4","gravatar_id":"","url":"https://api.github.com/users/Testably","html_url":"https://github.com/Testably","followers_url":"https://api.github.com/users/Testably/followers","following_url":"https://api.github.com/users/Testably/following{/other_user}","gists_url":"https://api.github.com/users/Testably/gists{/gist_id}","starred_url":"https://api.github.com/users/Testably/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Testably/subscriptions","organizations_url":"https://api.github.com/users/Testably/orgs","repos_url":"https://api.github.com/users/Testably/repos","events_url":"https://api.github.com/users/Testably/events{/privacy}","received_events_url":"https://api.github.com/users/Testably/received_events","type":"Organization","site_admin":false},"repo":{"id":779599291,"node_id":"R_kgDOLne9uw","name":"Testably.Server","full_name":"Testably/Testably.Server","private":false,"owner":{"login":"Testably","id":113782592,"node_id":"O_kgDOBsgvQA","avatar_url":"https://avatars.githubusercontent.com/u/113782592?v=4","gravatar_id":"","url":"https://api.github.com/users/Testably","html_url":"https://github.com/Testably","followers_url":"https://api.github.com/users/Testably/followers","following_url":"https://api.github.com/users/Testably/following{/other_user}","gists_url":"https://api.github.com/users/Testably/gists{/gist_id}","starred_url":"https://api.github.com/users/Testably/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Testably/subscriptions","organizations_url":"https://api.github.com/users/Testably/orgs","repos_url":"https://api.github.com/users/Testably/repos","events_url":"https://api.github.com/users/Testably/events{/privacy}","received_events_url":"https://api.github.com/users/Testably/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/Testably/Testably.Server","description":"The server for the Testably projects.","fork":false,"url":"https://api.github.com/repos/Testably/Testably.Server","forks_url":"https://api.github.com/repos/Testably/Testably.Server/forks","keys_url":"https://api.github.com/repos/Testably/Testably.Server/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Testably/Testably.Server/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Testably/Testably.Server/teams","hooks_url":"https://api.github.com/repos/Testably/Testably.Server/hooks","issue_events_url":"https://api.github.com/repos/Testably/Testably.Server/issues/events{/number}","events_url":"https://api.github.com/repos/Testably/Testably.Server/events","assignees_url":"https://api.github.com/repos/Testably/Testably.Server/assignees{/user}","branches_url":"https://api.github.com/repos/Testably/Testably.Server/branches{/branch}","tags_url":"https://api.github.com/repos/Testably/Testably.Server/tags","blobs_url":"https://api.github.com/repos/Testably/Testably.Server/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Testably/Testably.Server/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Testably/Testably.Server/git/refs{/sha}","trees_url":"https://api.github.com/repos/Testably/Testably.Server/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Testably/Testably.Server/statuses/{sha}","languages_url":"https://api.github.com/repos/Testably/Testably.Server/languages","stargazers_url":"https://api.github.com/repos/Testably/Testably.Server/stargazers","contributors_url":"https://api.github.com/repos/Testably/Testably.Server/contributors","subscribers_url":"https://api.github.com/repos/Testably/Testably.Server/subscribers","subscription_url":"https://api.github.com/repos/Testably/Testably.Server/subscription","commits_url":"https://api.github.com/repos/Testably/Testably.Server/commits{/sha}","git_commits_url":"https://api.github.com/repos/Testably/Testably.Server/git/commits{/sha}","comments_url":"https://api.github.com/repos/Testably/Testably.Server/comments{/number}","issue_comment_url":"https://api.github.com/repos/Testably/Testably.Server/issues/comments{/number}","contents_url":"https://api.github.com/repos/Testably/Testably.Server/contents/{+path}","compare_url":"https://api.github.com/repos/Testably/Testably.Server/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Testably/Testably.Server/merges","archive_url":"https://api.github.com/repos/Testably/Testably.Server/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Testably/Testably.Server/downloads","issues_url":"https://api.github.com/repos/Testably/Testably.Server/issues{/number}","pulls_url":"https://api.github.com/repos/Testably/Testably.Server/pulls{/number}","milestones_url":"https://api.github.com/repos/Testably/Testably.Server/milestones{/number}","notifications_url":"https://api.github.com/repos/Testably/Testably.Server/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Testably/Testably.Server/labels{/name}","releases_url":"https://api.github.com/repos/Testably/Testably.Server/releases{/id}","deployments_url":"https://api.github.com/repos/Testably/Testably.Server/deployments","created_at":"2024-03-30T09:08:11Z","updated_at":"2024-03-30T10:16:47Z","pushed_at":"2024-03-30T09:40:31Z","git_url":"git://github.com/Testably/Testably.Server.git","ssh_url":"git@github.com:Testably/Testably.Server.git","clone_url":"https://github.com/Testably/Testably.Server.git","svn_url":"https://github.com/Testably/Testably.Server","homepage":"","size":17,"stargazers_count":0,"watchers_count":0,"language":null,"has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"has_discussions":false,"forks_count":0,"mirror_url":null,"archived":false,"disabled":false,"open_issues_count":1,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit","node_id":"MDc6TGljZW5zZTEz"},"allow_forking":true,"is_template":false,"web_commit_signoff_required":false,"topics":[],"visibility":"public","forks":0,"open_issues":1,"watchers":0,"default_branch":"main","allow_squash_merge":true,"allow_merge_commit":true,"allow_rebase_merge":true,"allow_auto_merge":false,"delete_branch_on_merge":false,"allow_update_branch":false,"use_squash_pr_title_as_default":false,"squash_merge_commit_message":"COMMIT_MESSAGES","squash_merge_commit_title":"COMMIT_OR_PR_TITLE","merge_commit_message":"PR_TITLE","merge_commit_title":"MERGE_MESSAGE"}},"_links":{"self":{"href":"https://api.github.com/repos/Testably/Testably.Server/pulls/1"},"html":{"href":"https://github.com/Testably/Testably.Server/pull/1"},"issue":{"href":"https://api.github.com/repos/Testably/Testably.Server/issues/1"},"comments":{"href":"https://api.github.com/repos/Testably/Testably.Server/issues/1/comments"},"review_comments":{"href":"https://api.github.com/repos/Testably/Testably.Server/pulls/1/comments"},"review_comment":{"href":"https://api.github.com/repos/Testably/Testably.Server/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/Testably/Testably.Server/pulls/1/commits"},"statuses":{"href":"https://api.github.com/repos/Testably/Testably.Server/statuses/21fca141f27cec38edf14c405c7413b3a3f6c6ed"}},"author_association":"MEMBER","auto_merge":null,"active_lock_reason":null,"merged":false,"mergeable":true,"rebaseable":true,"mergeable_state":"clean","merged_by":null,"comments":0,"review_comments":0,"maintainer_can_modify":false,"commits":1,"additions":897,"deletions":0,"changed_files":23},"changes":{"title":{"from":"feat: create a PR"}},"repository":{"id":779599291,"node_id":"R_kgDOLne9uw","name":"Testably.Server","full_name":"Testably/Testably.Server","private":false,"owner":{"login":"Testably","id":113782592,"node_id":"O_kgDOBsgvQA","avatar_url":"https://avatars.githubusercontent.com/u/113782592?v=4","gravatar_id":"","url":"https://api.github.com/users/Testably","html_url":"https://github.com/Testably","followers_url":"https://api.github.com/users/Testably/followers","following_url":"https://api.github.com/users/Testably/following{/other_user}","gists_url":"https://api.github.com/users/Testably/gists{/gist_id}","starred_url":"https://api.github.com/users/Testably/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Testably/subscriptions","organizations_url":"https://api.github.com/users/Testably/orgs","repos_url":"https://api.github.com/users/Testably/repos","events_url":"https://api.github.com/users/Testably/events{/privacy}","received_events_url":"https://api.github.com/users/Testably/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/Testably/Testably.Server","description":"The server for the Testably projects.","fork":false,"url":"https://api.github.com/repos/Testably/Testably.Server","forks_url":"https://api.github.com/repos/Testably/Testably.Server/forks","keys_url":"https://api.github.com/repos/Testably/Testably.Server/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Testably/Testably.Server/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Testably/Testably.Server/teams","hooks_url":"https://api.github.com/repos/Testably/Testably.Server/hooks","issue_events_url":"https://api.github.com/repos/Testably/Testably.Server/issues/events{/number}","events_url":"https://api.github.com/repos/Testably/Testably.Server/events","assignees_url":"https://api.github.com/repos/Testably/Testably.Server/assignees{/user}","branches_url":"https://api.github.com/repos/Testably/Testably.Server/branches{/branch}","tags_url":"https://api.github.com/repos/Testably/Testably.Server/tags","blobs_url":"https://api.github.com/repos/Testably/Testably.Server/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Testably/Testably.Server/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Testably/Testably.Server/git/refs{/sha}","trees_url":"https://api.github.com/repos/Testably/Testably.Server/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Testably/Testably.Server/statuses/{sha}","languages_url":"https://api.github.com/repos/Testably/Testably.Server/languages","stargazers_url":"https://api.github.com/repos/Testably/Testably.Server/stargazers","contributors_url":"https://api.github.com/repos/Testably/Testably.Server/contributors","subscribers_url":"https://api.github.com/repos/Testably/Testably.Server/subscribers","subscription_url":"https://api.github.com/repos/Testably/Testably.Server/subscription","commits_url":"https://api.github.com/repos/Testably/Testably.Server/commits{/sha}","git_commits_url":"https://api.github.com/repos/Testably/Testably.Server/git/commits{/sha}","comments_url":"https://api.github.com/repos/Testably/Testably.Server/comments{/number}","issue_comment_url":"https://api.github.com/repos/Testably/Testably.Server/issues/comments{/number}","contents_url":"https://api.github.com/repos/Testably/Testably.Server/contents/{+path}","compare_url":"https://api.github.com/repos/Testably/Testably.Server/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Testably/Testably.Server/merges","archive_url":"https://api.github.com/repos/Testably/Testably.Server/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Testably/Testably.Server/downloads","issues_url":"https://api.github.com/repos/Testably/Testably.Server/issues{/number}","pulls_url":"https://api.github.com/repos/Testably/Testably.Server/pulls{/number}","milestones_url":"https://api.github.com/repos/Testably/Testably.Server/milestones{/number}","notifications_url":"https://api.github.com/repos/Testably/Testably.Server/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Testably/Testably.Server/labels{/name}","releases_url":"https://api.github.com/repos/Testably/Testably.Server/releases{/id}","deployments_url":"https://api.github.com/repos/Testably/Testably.Server/deployments","created_at":"2024-03-30T09:08:11Z","updated_at":"2024-03-30T10:16:47Z","pushed_at":"2024-03-30T09:40:31Z","git_url":"git://github.com/Testably/Testably.Server.git","ssh_url":"git@github.com:Testably/Testably.Server.git","clone_url":"https://github.com/Testably/Testably.Server.git","svn_url":"https://github.com/Testably/Testably.Server","homepage":"","size":17,"stargazers_count":0,"watchers_count":0,"language":null,"has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"has_discussions":false,"forks_count":0,"mirror_url":null,"archived":false,"disabled":false,"open_issues_count":1,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit","node_id":"MDc6TGljZW5zZTEz"},"allow_forking":true,"is_template":false,"web_commit_signoff_required":false,"topics":[],"visibility":"public","forks":0,"open_issues":1,"watchers":0,"default_branch":"main","custom_properties":{}},"organization":{"login":"Testably","id":113782592,"node_id":"O_kgDOBsgvQA","url":"https://api.github.com/orgs/Testably","repos_url":"https://api.github.com/orgs/Testably/repos","events_url":"https://api.github.com/orgs/Testably/events","hooks_url":"https://api.github.com/orgs/Testably/hooks","issues_url":"https://api.github.com/orgs/Testably/issues","members_url":"https://api.github.com/orgs/Testably/members{/member}","public_members_url":"https://api.github.com/orgs/Testably/public_members{/member}","avatar_url":"https://avatars.githubusercontent.com/u/113782592?v=4","description":""},"sender":{"login":"vbreuss","id":3438234,"node_id":"MDQ6VXNlcjM0MzgyMzQ=","avatar_url":"https://avatars.githubusercontent.com/u/3438234?v=4","gravatar_id":"","url":"https://api.github.com/users/vbreuss","html_url":"https://github.com/vbreuss","followers_url":"https://api.github.com/users/vbreuss/followers","following_url":"https://api.github.com/users/vbreuss/following{/other_user}","gists_url":"https://api.github.com/users/vbreuss/gists{/gist_id}","starred_url":"https://api.github.com/users/vbreuss/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vbreuss/subscriptions","organizations_url":"https://api.github.com/users/vbreuss/orgs","repos_url":"https://api.github.com/users/vbreuss/repos","events_url":"https://api.github.com/users/vbreuss/events{/privacy}","received_events_url":"https://api.github.com/users/vbreuss/received_events","type":"User","site_admin":false}}} - """; - var githubResponse = - $$$""" - {"url":"https://api.github.com/repos/Testably/Testably.Server/pulls/1","id":1798848450,"node_id":"PR_kwDOLne9u85rOD_C","html_url":"https://github.com/Testably/Testably.Server/pull/1","diff_url":"https://github.com/Testably/Testably.Server/pull/1.diff","patch_url":"https://github.com/Testably/Testably.Server/pull/1.patch","issue_url":"https://api.github.com/repos/Testably/Testably.Server/issues/1","number":1,"state":"open","locked":false,"title":"{{{title}}}","user":{"login":"vbreuss","id":3438234,"node_id":"MDQ6VXNlcjM0MzgyMzQ=","avatar_url":"https://avatars.githubusercontent.com/u/3438234?v=4","gravatar_id":"","url":"https://api.github.com/users/vbreuss","html_url":"https://github.com/vbreuss","followers_url":"https://api.github.com/users/vbreuss/followers","following_url":"https://api.github.com/users/vbreuss/following{/other_user}","gists_url":"https://api.github.com/users/vbreuss/gists{/gist_id}","starred_url":"https://api.github.com/users/vbreuss/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vbreuss/subscriptions","organizations_url":"https://api.github.com/users/vbreuss/orgs","repos_url":"https://api.github.com/users/vbreuss/repos","events_url":"https://api.github.com/users/vbreuss/events{/privacy}","received_events_url":"https://api.github.com/users/vbreuss/received_events","type":"User","site_admin":false},"body":null,"created_at":"2024-03-30T09:40:30Z","updated_at":"2024-03-30T10:19:35Z","closed_at":null,"merged_at":null,"merge_commit_sha":"c58bf0ce4d7ed8a0c5efef05eb593e0ef5f2ec9e","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"draft":false,"commits_url":"https://api.github.com/repos/Testably/Testably.Server/pulls/1/commits","review_comments_url":"https://api.github.com/repos/Testably/Testably.Server/pulls/1/comments","review_comment_url":"https://api.github.com/repos/Testably/Testably.Server/pulls/comments{/number}","comments_url":"https://api.github.com/repos/Testably/Testably.Server/issues/1/comments","statuses_url":"https://api.github.com/repos/Testably/Testably.Server/statuses/21fca141f27cec38edf14c405c7413b3a3f6c6ed","head":{"label":"Testably:topic/add-initial-project","ref":"topic/add-initial-project","sha":"21fca141f27cec38edf14c405c7413b3a3f6c6ed","user":{"login":"Testably","id":113782592,"node_id":"O_kgDOBsgvQA","avatar_url":"https://avatars.githubusercontent.com/u/113782592?v=4","gravatar_id":"","url":"https://api.github.com/users/Testably","html_url":"https://github.com/Testably","followers_url":"https://api.github.com/users/Testably/followers","following_url":"https://api.github.com/users/Testably/following{/other_user}","gists_url":"https://api.github.com/users/Testably/gists{/gist_id}","starred_url":"https://api.github.com/users/Testably/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Testably/subscriptions","organizations_url":"https://api.github.com/users/Testably/orgs","repos_url":"https://api.github.com/users/Testably/repos","events_url":"https://api.github.com/users/Testably/events{/privacy}","received_events_url":"https://api.github.com/users/Testably/received_events","type":"Organization","site_admin":false},"repo":{"id":779599291,"node_id":"R_kgDOLne9uw","name":"Testably.Server","full_name":"Testably/Testably.Server","private":false,"owner":{"login":"Testably","id":113782592,"node_id":"O_kgDOBsgvQA","avatar_url":"https://avatars.githubusercontent.com/u/113782592?v=4","gravatar_id":"","url":"https://api.github.com/users/Testably","html_url":"https://github.com/Testably","followers_url":"https://api.github.com/users/Testably/followers","following_url":"https://api.github.com/users/Testably/following{/other_user}","gists_url":"https://api.github.com/users/Testably/gists{/gist_id}","starred_url":"https://api.github.com/users/Testably/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Testably/subscriptions","organizations_url":"https://api.github.com/users/Testably/orgs","repos_url":"https://api.github.com/users/Testably/repos","events_url":"https://api.github.com/users/Testably/events{/privacy}","received_events_url":"https://api.github.com/users/Testably/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/Testably/Testably.Server","description":"The server for the Testably projects.","fork":false,"url":"https://api.github.com/repos/Testably/Testably.Server","forks_url":"https://api.github.com/repos/Testably/Testably.Server/forks","keys_url":"https://api.github.com/repos/Testably/Testably.Server/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Testably/Testably.Server/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Testably/Testably.Server/teams","hooks_url":"https://api.github.com/repos/Testably/Testably.Server/hooks","issue_events_url":"https://api.github.com/repos/Testably/Testably.Server/issues/events{/number}","events_url":"https://api.github.com/repos/Testably/Testably.Server/events","assignees_url":"https://api.github.com/repos/Testably/Testably.Server/assignees{/user}","branches_url":"https://api.github.com/repos/Testably/Testably.Server/branches{/branch}","tags_url":"https://api.github.com/repos/Testably/Testably.Server/tags","blobs_url":"https://api.github.com/repos/Testably/Testably.Server/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Testably/Testably.Server/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Testably/Testably.Server/git/refs{/sha}","trees_url":"https://api.github.com/repos/Testably/Testably.Server/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Testably/Testably.Server/statuses/{sha}","languages_url":"https://api.github.com/repos/Testably/Testably.Server/languages","stargazers_url":"https://api.github.com/repos/Testably/Testably.Server/stargazers","contributors_url":"https://api.github.com/repos/Testably/Testably.Server/contributors","subscribers_url":"https://api.github.com/repos/Testably/Testably.Server/subscribers","subscription_url":"https://api.github.com/repos/Testably/Testably.Server/subscription","commits_url":"https://api.github.com/repos/Testably/Testably.Server/commits{/sha}","git_commits_url":"https://api.github.com/repos/Testably/Testably.Server/git/commits{/sha}","comments_url":"https://api.github.com/repos/Testably/Testably.Server/comments{/number}","issue_comment_url":"https://api.github.com/repos/Testably/Testably.Server/issues/comments{/number}","contents_url":"https://api.github.com/repos/Testably/Testably.Server/contents/{+path}","compare_url":"https://api.github.com/repos/Testably/Testably.Server/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Testably/Testably.Server/merges","archive_url":"https://api.github.com/repos/Testably/Testably.Server/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Testably/Testably.Server/downloads","issues_url":"https://api.github.com/repos/Testably/Testably.Server/issues{/number}","pulls_url":"https://api.github.com/repos/Testably/Testably.Server/pulls{/number}","milestones_url":"https://api.github.com/repos/Testably/Testably.Server/milestones{/number}","notifications_url":"https://api.github.com/repos/Testably/Testably.Server/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Testably/Testably.Server/labels{/name}","releases_url":"https://api.github.com/repos/Testably/Testably.Server/releases{/id}","deployments_url":"https://api.github.com/repos/Testably/Testably.Server/deployments","created_at":"2024-03-30T09:08:11Z","updated_at":"2024-03-30T10:16:47Z","pushed_at":"2024-03-30T09:40:31Z","git_url":"git://github.com/Testably/Testably.Server.git","ssh_url":"git@github.com:Testably/Testably.Server.git","clone_url":"https://github.com/Testably/Testably.Server.git","svn_url":"https://github.com/Testably/Testably.Server","homepage":"","size":17,"stargazers_count":0,"watchers_count":0,"language":null,"has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"has_discussions":false,"forks_count":0,"mirror_url":null,"archived":false,"disabled":false,"open_issues_count":1,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit","node_id":"MDc6TGljZW5zZTEz"},"allow_forking":true,"is_template":false,"web_commit_signoff_required":false,"topics":[],"visibility":"public","forks":0,"open_issues":1,"watchers":0,"default_branch":"main"}},"base":{"label":"Testably:main","ref":"main","sha":"2a08a4ac7915f896c25838fab56c8711e6dd2220","user":{"login":"Testably","id":113782592,"node_id":"O_kgDOBsgvQA","avatar_url":"https://avatars.githubusercontent.com/u/113782592?v=4","gravatar_id":"","url":"https://api.github.com/users/Testably","html_url":"https://github.com/Testably","followers_url":"https://api.github.com/users/Testably/followers","following_url":"https://api.github.com/users/Testably/following{/other_user}","gists_url":"https://api.github.com/users/Testably/gists{/gist_id}","starred_url":"https://api.github.com/users/Testably/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Testably/subscriptions","organizations_url":"https://api.github.com/users/Testably/orgs","repos_url":"https://api.github.com/users/Testably/repos","events_url":"https://api.github.com/users/Testably/events{/privacy}","received_events_url":"https://api.github.com/users/Testably/received_events","type":"Organization","site_admin":false},"repo":{"id":779599291,"node_id":"R_kgDOLne9uw","name":"Testably.Server","full_name":"Testably/Testably.Server","private":false,"owner":{"login":"Testably","id":113782592,"node_id":"O_kgDOBsgvQA","avatar_url":"https://avatars.githubusercontent.com/u/113782592?v=4","gravatar_id":"","url":"https://api.github.com/users/Testably","html_url":"https://github.com/Testably","followers_url":"https://api.github.com/users/Testably/followers","following_url":"https://api.github.com/users/Testably/following{/other_user}","gists_url":"https://api.github.com/users/Testably/gists{/gist_id}","starred_url":"https://api.github.com/users/Testably/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Testably/subscriptions","organizations_url":"https://api.github.com/users/Testably/orgs","repos_url":"https://api.github.com/users/Testably/repos","events_url":"https://api.github.com/users/Testably/events{/privacy}","received_events_url":"https://api.github.com/users/Testably/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/Testably/Testably.Server","description":"The server for the Testably projects.","fork":false,"url":"https://api.github.com/repos/Testably/Testably.Server","forks_url":"https://api.github.com/repos/Testably/Testably.Server/forks","keys_url":"https://api.github.com/repos/Testably/Testably.Server/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Testably/Testably.Server/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Testably/Testably.Server/teams","hooks_url":"https://api.github.com/repos/Testably/Testably.Server/hooks","issue_events_url":"https://api.github.com/repos/Testably/Testably.Server/issues/events{/number}","events_url":"https://api.github.com/repos/Testably/Testably.Server/events","assignees_url":"https://api.github.com/repos/Testably/Testably.Server/assignees{/user}","branches_url":"https://api.github.com/repos/Testably/Testably.Server/branches{/branch}","tags_url":"https://api.github.com/repos/Testably/Testably.Server/tags","blobs_url":"https://api.github.com/repos/Testably/Testably.Server/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Testably/Testably.Server/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Testably/Testably.Server/git/refs{/sha}","trees_url":"https://api.github.com/repos/Testably/Testably.Server/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Testably/Testably.Server/statuses/{sha}","languages_url":"https://api.github.com/repos/Testably/Testably.Server/languages","stargazers_url":"https://api.github.com/repos/Testably/Testably.Server/stargazers","contributors_url":"https://api.github.com/repos/Testably/Testably.Server/contributors","subscribers_url":"https://api.github.com/repos/Testably/Testably.Server/subscribers","subscription_url":"https://api.github.com/repos/Testably/Testably.Server/subscription","commits_url":"https://api.github.com/repos/Testably/Testably.Server/commits{/sha}","git_commits_url":"https://api.github.com/repos/Testably/Testably.Server/git/commits{/sha}","comments_url":"https://api.github.com/repos/Testably/Testably.Server/comments{/number}","issue_comment_url":"https://api.github.com/repos/Testably/Testably.Server/issues/comments{/number}","contents_url":"https://api.github.com/repos/Testably/Testably.Server/contents/{+path}","compare_url":"https://api.github.com/repos/Testably/Testably.Server/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Testably/Testably.Server/merges","archive_url":"https://api.github.com/repos/Testably/Testably.Server/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Testably/Testably.Server/downloads","issues_url":"https://api.github.com/repos/Testably/Testably.Server/issues{/number}","pulls_url":"https://api.github.com/repos/Testably/Testably.Server/pulls{/number}","milestones_url":"https://api.github.com/repos/Testably/Testably.Server/milestones{/number}","notifications_url":"https://api.github.com/repos/Testably/Testably.Server/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Testably/Testably.Server/labels{/name}","releases_url":"https://api.github.com/repos/Testably/Testably.Server/releases{/id}","deployments_url":"https://api.github.com/repos/Testably/Testably.Server/deployments","created_at":"2024-03-30T09:08:11Z","updated_at":"2024-03-30T10:16:47Z","pushed_at":"2024-03-30T09:40:31Z","git_url":"git://github.com/Testably/Testably.Server.git","ssh_url":"git@github.com:Testably/Testably.Server.git","clone_url":"https://github.com/Testably/Testably.Server.git","svn_url":"https://github.com/Testably/Testably.Server","homepage":"","size":17,"stargazers_count":0,"watchers_count":0,"language":null,"has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"has_discussions":false,"forks_count":0,"mirror_url":null,"archived":false,"disabled":false,"open_issues_count":1,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit","node_id":"MDc6TGljZW5zZTEz"},"allow_forking":true,"is_template":false,"web_commit_signoff_required":false,"topics":[],"visibility":"public","forks":0,"open_issues":1,"watchers":0,"default_branch":"main"}},"_links":{"self":{"href":"https://api.github.com/repos/Testably/Testably.Server/pulls/1"},"html":{"href":"https://github.com/Testably/Testably.Server/pull/1"},"issue":{"href":"https://api.github.com/repos/Testably/Testably.Server/issues/1"},"comments":{"href":"https://api.github.com/repos/Testably/Testably.Server/issues/1/comments"},"review_comments":{"href":"https://api.github.com/repos/Testably/Testably.Server/pulls/1/comments"},"review_comment":{"href":"https://api.github.com/repos/Testably/Testably.Server/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/Testably/Testably.Server/pulls/1/commits"},"statuses":{"href":"https://api.github.com/repos/Testably/Testably.Server/statuses/21fca141f27cec38edf14c405c7413b3a3f6c6ed"}},"author_association":"MEMBER","auto_merge":null,"active_lock_reason":null,"merged":false,"mergeable":true,"rebaseable":true,"mergeable_state":"clean","merged_by":null,"comments":0,"review_comments":0,"maintainer_can_modify":false,"commits":1,"additions":897,"deletions":0,"changed_files":23} - """; - string? sentStatusCheck = null; - var httpClientFactoryMock = MockHttpClientFactory(( - r => r.Method == HttpMethod.Get && r.RequestUri!.AbsoluteUri.StartsWith( - "https://api.github.com/repos/Testably/Testably.Server/pulls/1"), - _ => githubResponse), - ( - r => r.Method == HttpMethod.Post && r.RequestUri!.AbsoluteUri.StartsWith( - "https://api.github.com/repos/Testably/Testably.Server/statuses"), - c => - { - sentStatusCheck = c; - return ""; - })); - await using var factory = new TestFactory(httpClientFactoryMock.Object); - using var client = factory.CreateClient(); - using var content = new StringContent(webhookPayload, mediaType: "application/json", - encoding: Encoding.UTF8); + [Theory] + [InlineData("feat: foo", "success")] + [InlineData("invalid", "failure")] + public async Task HappyCase_ShouldSucceed(string title, string status) + { + var webhookPayload = + """ + {"action":"edited","number":1,"pull_request":{"url":"https://api.github.com/repos/Testably/Testably.Server/pulls/1","id":1798848450,"node_id":"PR_kwDOLne9u85rOD_C","html_url":"https://github.com/Testably/Testably.Server/pull/1","diff_url":"https://github.com/Testably/Testably.Server/pull/1.diff","patch_url":"https://github.com/Testably/Testably.Server/pull/1.patch","issue_url":"https://api.github.com/repos/Testably/Testably.Server/issues/1","number":1,"state":"open","locked":false,"title":"feat: create a PR2","user":{"login":"vbreuss","id":3438234,"node_id":"MDQ6VXNlcjM0MzgyMzQ=","avatar_url":"https://avatars.githubusercontent.com/u/3438234?v=4","gravatar_id":"","url":"https://api.github.com/users/vbreuss","html_url":"https://github.com/vbreuss","followers_url":"https://api.github.com/users/vbreuss/followers","following_url":"https://api.github.com/users/vbreuss/following{/other_user}","gists_url":"https://api.github.com/users/vbreuss/gists{/gist_id}","starred_url":"https://api.github.com/users/vbreuss/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vbreuss/subscriptions","organizations_url":"https://api.github.com/users/vbreuss/orgs","repos_url":"https://api.github.com/users/vbreuss/repos","events_url":"https://api.github.com/users/vbreuss/events{/privacy}","received_events_url":"https://api.github.com/users/vbreuss/received_events","type":"User","site_admin":false},"body":null,"created_at":"2024-03-30T09:40:30Z","updated_at":"2024-03-30T10:19:35Z","closed_at":null,"merged_at":null,"merge_commit_sha":"c58bf0ce4d7ed8a0c5efef05eb593e0ef5f2ec9e","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"draft":false,"commits_url":"https://api.github.com/repos/Testably/Testably.Server/pulls/1/commits","review_comments_url":"https://api.github.com/repos/Testably/Testably.Server/pulls/1/comments","review_comment_url":"https://api.github.com/repos/Testably/Testably.Server/pulls/comments{/number}","comments_url":"https://api.github.com/repos/Testably/Testably.Server/issues/1/comments","statuses_url":"https://api.github.com/repos/Testably/Testably.Server/statuses/21fca141f27cec38edf14c405c7413b3a3f6c6ed","head":{"label":"Testably:topic/add-initial-project","ref":"topic/add-initial-project","sha":"21fca141f27cec38edf14c405c7413b3a3f6c6ed","user":{"login":"Testably","id":113782592,"node_id":"O_kgDOBsgvQA","avatar_url":"https://avatars.githubusercontent.com/u/113782592?v=4","gravatar_id":"","url":"https://api.github.com/users/Testably","html_url":"https://github.com/Testably","followers_url":"https://api.github.com/users/Testably/followers","following_url":"https://api.github.com/users/Testably/following{/other_user}","gists_url":"https://api.github.com/users/Testably/gists{/gist_id}","starred_url":"https://api.github.com/users/Testably/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Testably/subscriptions","organizations_url":"https://api.github.com/users/Testably/orgs","repos_url":"https://api.github.com/users/Testably/repos","events_url":"https://api.github.com/users/Testably/events{/privacy}","received_events_url":"https://api.github.com/users/Testably/received_events","type":"Organization","site_admin":false},"repo":{"id":779599291,"node_id":"R_kgDOLne9uw","name":"Testably.Server","full_name":"Testably/Testably.Server","private":false,"owner":{"login":"Testably","id":113782592,"node_id":"O_kgDOBsgvQA","avatar_url":"https://avatars.githubusercontent.com/u/113782592?v=4","gravatar_id":"","url":"https://api.github.com/users/Testably","html_url":"https://github.com/Testably","followers_url":"https://api.github.com/users/Testably/followers","following_url":"https://api.github.com/users/Testably/following{/other_user}","gists_url":"https://api.github.com/users/Testably/gists{/gist_id}","starred_url":"https://api.github.com/users/Testably/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Testably/subscriptions","organizations_url":"https://api.github.com/users/Testably/orgs","repos_url":"https://api.github.com/users/Testably/repos","events_url":"https://api.github.com/users/Testably/events{/privacy}","received_events_url":"https://api.github.com/users/Testably/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/Testably/Testably.Server","description":"The server for the Testably projects.","fork":false,"url":"https://api.github.com/repos/Testably/Testably.Server","forks_url":"https://api.github.com/repos/Testably/Testably.Server/forks","keys_url":"https://api.github.com/repos/Testably/Testably.Server/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Testably/Testably.Server/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Testably/Testably.Server/teams","hooks_url":"https://api.github.com/repos/Testably/Testably.Server/hooks","issue_events_url":"https://api.github.com/repos/Testably/Testably.Server/issues/events{/number}","events_url":"https://api.github.com/repos/Testably/Testably.Server/events","assignees_url":"https://api.github.com/repos/Testably/Testably.Server/assignees{/user}","branches_url":"https://api.github.com/repos/Testably/Testably.Server/branches{/branch}","tags_url":"https://api.github.com/repos/Testably/Testably.Server/tags","blobs_url":"https://api.github.com/repos/Testably/Testably.Server/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Testably/Testably.Server/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Testably/Testably.Server/git/refs{/sha}","trees_url":"https://api.github.com/repos/Testably/Testably.Server/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Testably/Testably.Server/statuses/{sha}","languages_url":"https://api.github.com/repos/Testably/Testably.Server/languages","stargazers_url":"https://api.github.com/repos/Testably/Testably.Server/stargazers","contributors_url":"https://api.github.com/repos/Testably/Testably.Server/contributors","subscribers_url":"https://api.github.com/repos/Testably/Testably.Server/subscribers","subscription_url":"https://api.github.com/repos/Testably/Testably.Server/subscription","commits_url":"https://api.github.com/repos/Testably/Testably.Server/commits{/sha}","git_commits_url":"https://api.github.com/repos/Testably/Testably.Server/git/commits{/sha}","comments_url":"https://api.github.com/repos/Testably/Testably.Server/comments{/number}","issue_comment_url":"https://api.github.com/repos/Testably/Testably.Server/issues/comments{/number}","contents_url":"https://api.github.com/repos/Testably/Testably.Server/contents/{+path}","compare_url":"https://api.github.com/repos/Testably/Testably.Server/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Testably/Testably.Server/merges","archive_url":"https://api.github.com/repos/Testably/Testably.Server/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Testably/Testably.Server/downloads","issues_url":"https://api.github.com/repos/Testably/Testably.Server/issues{/number}","pulls_url":"https://api.github.com/repos/Testably/Testably.Server/pulls{/number}","milestones_url":"https://api.github.com/repos/Testably/Testably.Server/milestones{/number}","notifications_url":"https://api.github.com/repos/Testably/Testably.Server/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Testably/Testably.Server/labels{/name}","releases_url":"https://api.github.com/repos/Testably/Testably.Server/releases{/id}","deployments_url":"https://api.github.com/repos/Testably/Testably.Server/deployments","created_at":"2024-03-30T09:08:11Z","updated_at":"2024-03-30T10:16:47Z","pushed_at":"2024-03-30T09:40:31Z","git_url":"git://github.com/Testably/Testably.Server.git","ssh_url":"git@github.com:Testably/Testably.Server.git","clone_url":"https://github.com/Testably/Testably.Server.git","svn_url":"https://github.com/Testably/Testably.Server","homepage":"","size":17,"stargazers_count":0,"watchers_count":0,"language":null,"has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"has_discussions":false,"forks_count":0,"mirror_url":null,"archived":false,"disabled":false,"open_issues_count":1,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit","node_id":"MDc6TGljZW5zZTEz"},"allow_forking":true,"is_template":false,"web_commit_signoff_required":false,"topics":[],"visibility":"public","forks":0,"open_issues":1,"watchers":0,"default_branch":"main","allow_squash_merge":true,"allow_merge_commit":true,"allow_rebase_merge":true,"allow_auto_merge":false,"delete_branch_on_merge":false,"allow_update_branch":false,"use_squash_pr_title_as_default":false,"squash_merge_commit_message":"COMMIT_MESSAGES","squash_merge_commit_title":"COMMIT_OR_PR_TITLE","merge_commit_message":"PR_TITLE","merge_commit_title":"MERGE_MESSAGE"}},"base":{"label":"Testably:main","ref":"main","sha":"2a08a4ac7915f896c25838fab56c8711e6dd2220","user":{"login":"Testably","id":113782592,"node_id":"O_kgDOBsgvQA","avatar_url":"https://avatars.githubusercontent.com/u/113782592?v=4","gravatar_id":"","url":"https://api.github.com/users/Testably","html_url":"https://github.com/Testably","followers_url":"https://api.github.com/users/Testably/followers","following_url":"https://api.github.com/users/Testably/following{/other_user}","gists_url":"https://api.github.com/users/Testably/gists{/gist_id}","starred_url":"https://api.github.com/users/Testably/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Testably/subscriptions","organizations_url":"https://api.github.com/users/Testably/orgs","repos_url":"https://api.github.com/users/Testably/repos","events_url":"https://api.github.com/users/Testably/events{/privacy}","received_events_url":"https://api.github.com/users/Testably/received_events","type":"Organization","site_admin":false},"repo":{"id":779599291,"node_id":"R_kgDOLne9uw","name":"Testably.Server","full_name":"Testably/Testably.Server","private":false,"owner":{"login":"Testably","id":113782592,"node_id":"O_kgDOBsgvQA","avatar_url":"https://avatars.githubusercontent.com/u/113782592?v=4","gravatar_id":"","url":"https://api.github.com/users/Testably","html_url":"https://github.com/Testably","followers_url":"https://api.github.com/users/Testably/followers","following_url":"https://api.github.com/users/Testably/following{/other_user}","gists_url":"https://api.github.com/users/Testably/gists{/gist_id}","starred_url":"https://api.github.com/users/Testably/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Testably/subscriptions","organizations_url":"https://api.github.com/users/Testably/orgs","repos_url":"https://api.github.com/users/Testably/repos","events_url":"https://api.github.com/users/Testably/events{/privacy}","received_events_url":"https://api.github.com/users/Testably/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/Testably/Testably.Server","description":"The server for the Testably projects.","fork":false,"url":"https://api.github.com/repos/Testably/Testably.Server","forks_url":"https://api.github.com/repos/Testably/Testably.Server/forks","keys_url":"https://api.github.com/repos/Testably/Testably.Server/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Testably/Testably.Server/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Testably/Testably.Server/teams","hooks_url":"https://api.github.com/repos/Testably/Testably.Server/hooks","issue_events_url":"https://api.github.com/repos/Testably/Testably.Server/issues/events{/number}","events_url":"https://api.github.com/repos/Testably/Testably.Server/events","assignees_url":"https://api.github.com/repos/Testably/Testably.Server/assignees{/user}","branches_url":"https://api.github.com/repos/Testably/Testably.Server/branches{/branch}","tags_url":"https://api.github.com/repos/Testably/Testably.Server/tags","blobs_url":"https://api.github.com/repos/Testably/Testably.Server/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Testably/Testably.Server/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Testably/Testably.Server/git/refs{/sha}","trees_url":"https://api.github.com/repos/Testably/Testably.Server/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Testably/Testably.Server/statuses/{sha}","languages_url":"https://api.github.com/repos/Testably/Testably.Server/languages","stargazers_url":"https://api.github.com/repos/Testably/Testably.Server/stargazers","contributors_url":"https://api.github.com/repos/Testably/Testably.Server/contributors","subscribers_url":"https://api.github.com/repos/Testably/Testably.Server/subscribers","subscription_url":"https://api.github.com/repos/Testably/Testably.Server/subscription","commits_url":"https://api.github.com/repos/Testably/Testably.Server/commits{/sha}","git_commits_url":"https://api.github.com/repos/Testably/Testably.Server/git/commits{/sha}","comments_url":"https://api.github.com/repos/Testably/Testably.Server/comments{/number}","issue_comment_url":"https://api.github.com/repos/Testably/Testably.Server/issues/comments{/number}","contents_url":"https://api.github.com/repos/Testably/Testably.Server/contents/{+path}","compare_url":"https://api.github.com/repos/Testably/Testably.Server/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Testably/Testably.Server/merges","archive_url":"https://api.github.com/repos/Testably/Testably.Server/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Testably/Testably.Server/downloads","issues_url":"https://api.github.com/repos/Testably/Testably.Server/issues{/number}","pulls_url":"https://api.github.com/repos/Testably/Testably.Server/pulls{/number}","milestones_url":"https://api.github.com/repos/Testably/Testably.Server/milestones{/number}","notifications_url":"https://api.github.com/repos/Testably/Testably.Server/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Testably/Testably.Server/labels{/name}","releases_url":"https://api.github.com/repos/Testably/Testably.Server/releases{/id}","deployments_url":"https://api.github.com/repos/Testably/Testably.Server/deployments","created_at":"2024-03-30T09:08:11Z","updated_at":"2024-03-30T10:16:47Z","pushed_at":"2024-03-30T09:40:31Z","git_url":"git://github.com/Testably/Testably.Server.git","ssh_url":"git@github.com:Testably/Testably.Server.git","clone_url":"https://github.com/Testably/Testably.Server.git","svn_url":"https://github.com/Testably/Testably.Server","homepage":"","size":17,"stargazers_count":0,"watchers_count":0,"language":null,"has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"has_discussions":false,"forks_count":0,"mirror_url":null,"archived":false,"disabled":false,"open_issues_count":1,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit","node_id":"MDc6TGljZW5zZTEz"},"allow_forking":true,"is_template":false,"web_commit_signoff_required":false,"topics":[],"visibility":"public","forks":0,"open_issues":1,"watchers":0,"default_branch":"main","allow_squash_merge":true,"allow_merge_commit":true,"allow_rebase_merge":true,"allow_auto_merge":false,"delete_branch_on_merge":false,"allow_update_branch":false,"use_squash_pr_title_as_default":false,"squash_merge_commit_message":"COMMIT_MESSAGES","squash_merge_commit_title":"COMMIT_OR_PR_TITLE","merge_commit_message":"PR_TITLE","merge_commit_title":"MERGE_MESSAGE"}},"_links":{"self":{"href":"https://api.github.com/repos/Testably/Testably.Server/pulls/1"},"html":{"href":"https://github.com/Testably/Testably.Server/pull/1"},"issue":{"href":"https://api.github.com/repos/Testably/Testably.Server/issues/1"},"comments":{"href":"https://api.github.com/repos/Testably/Testably.Server/issues/1/comments"},"review_comments":{"href":"https://api.github.com/repos/Testably/Testably.Server/pulls/1/comments"},"review_comment":{"href":"https://api.github.com/repos/Testably/Testably.Server/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/Testably/Testably.Server/pulls/1/commits"},"statuses":{"href":"https://api.github.com/repos/Testably/Testably.Server/statuses/21fca141f27cec38edf14c405c7413b3a3f6c6ed"}},"author_association":"MEMBER","auto_merge":null,"active_lock_reason":null,"merged":false,"mergeable":true,"rebaseable":true,"mergeable_state":"clean","merged_by":null,"comments":0,"review_comments":0,"maintainer_can_modify":false,"commits":1,"additions":897,"deletions":0,"changed_files":23},"changes":{"title":{"from":"feat: create a PR"}},"repository":{"id":779599291,"node_id":"R_kgDOLne9uw","name":"Testably.Server","full_name":"Testably/Testably.Server","private":false,"owner":{"login":"Testably","id":113782592,"node_id":"O_kgDOBsgvQA","avatar_url":"https://avatars.githubusercontent.com/u/113782592?v=4","gravatar_id":"","url":"https://api.github.com/users/Testably","html_url":"https://github.com/Testably","followers_url":"https://api.github.com/users/Testably/followers","following_url":"https://api.github.com/users/Testably/following{/other_user}","gists_url":"https://api.github.com/users/Testably/gists{/gist_id}","starred_url":"https://api.github.com/users/Testably/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Testably/subscriptions","organizations_url":"https://api.github.com/users/Testably/orgs","repos_url":"https://api.github.com/users/Testably/repos","events_url":"https://api.github.com/users/Testably/events{/privacy}","received_events_url":"https://api.github.com/users/Testably/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/Testably/Testably.Server","description":"The server for the Testably projects.","fork":false,"url":"https://api.github.com/repos/Testably/Testably.Server","forks_url":"https://api.github.com/repos/Testably/Testably.Server/forks","keys_url":"https://api.github.com/repos/Testably/Testably.Server/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Testably/Testably.Server/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Testably/Testably.Server/teams","hooks_url":"https://api.github.com/repos/Testably/Testably.Server/hooks","issue_events_url":"https://api.github.com/repos/Testably/Testably.Server/issues/events{/number}","events_url":"https://api.github.com/repos/Testably/Testably.Server/events","assignees_url":"https://api.github.com/repos/Testably/Testably.Server/assignees{/user}","branches_url":"https://api.github.com/repos/Testably/Testably.Server/branches{/branch}","tags_url":"https://api.github.com/repos/Testably/Testably.Server/tags","blobs_url":"https://api.github.com/repos/Testably/Testably.Server/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Testably/Testably.Server/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Testably/Testably.Server/git/refs{/sha}","trees_url":"https://api.github.com/repos/Testably/Testably.Server/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Testably/Testably.Server/statuses/{sha}","languages_url":"https://api.github.com/repos/Testably/Testably.Server/languages","stargazers_url":"https://api.github.com/repos/Testably/Testably.Server/stargazers","contributors_url":"https://api.github.com/repos/Testably/Testably.Server/contributors","subscribers_url":"https://api.github.com/repos/Testably/Testably.Server/subscribers","subscription_url":"https://api.github.com/repos/Testably/Testably.Server/subscription","commits_url":"https://api.github.com/repos/Testably/Testably.Server/commits{/sha}","git_commits_url":"https://api.github.com/repos/Testably/Testably.Server/git/commits{/sha}","comments_url":"https://api.github.com/repos/Testably/Testably.Server/comments{/number}","issue_comment_url":"https://api.github.com/repos/Testably/Testably.Server/issues/comments{/number}","contents_url":"https://api.github.com/repos/Testably/Testably.Server/contents/{+path}","compare_url":"https://api.github.com/repos/Testably/Testably.Server/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Testably/Testably.Server/merges","archive_url":"https://api.github.com/repos/Testably/Testably.Server/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Testably/Testably.Server/downloads","issues_url":"https://api.github.com/repos/Testably/Testably.Server/issues{/number}","pulls_url":"https://api.github.com/repos/Testably/Testably.Server/pulls{/number}","milestones_url":"https://api.github.com/repos/Testably/Testably.Server/milestones{/number}","notifications_url":"https://api.github.com/repos/Testably/Testably.Server/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Testably/Testably.Server/labels{/name}","releases_url":"https://api.github.com/repos/Testably/Testably.Server/releases{/id}","deployments_url":"https://api.github.com/repos/Testably/Testably.Server/deployments","created_at":"2024-03-30T09:08:11Z","updated_at":"2024-03-30T10:16:47Z","pushed_at":"2024-03-30T09:40:31Z","git_url":"git://github.com/Testably/Testably.Server.git","ssh_url":"git@github.com:Testably/Testably.Server.git","clone_url":"https://github.com/Testably/Testably.Server.git","svn_url":"https://github.com/Testably/Testably.Server","homepage":"","size":17,"stargazers_count":0,"watchers_count":0,"language":null,"has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"has_discussions":false,"forks_count":0,"mirror_url":null,"archived":false,"disabled":false,"open_issues_count":1,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit","node_id":"MDc6TGljZW5zZTEz"},"allow_forking":true,"is_template":false,"web_commit_signoff_required":false,"topics":[],"visibility":"public","forks":0,"open_issues":1,"watchers":0,"default_branch":"main","custom_properties":{}},"organization":{"login":"Testably","id":113782592,"node_id":"O_kgDOBsgvQA","url":"https://api.github.com/orgs/Testably","repos_url":"https://api.github.com/orgs/Testably/repos","events_url":"https://api.github.com/orgs/Testably/events","hooks_url":"https://api.github.com/orgs/Testably/hooks","issues_url":"https://api.github.com/orgs/Testably/issues","members_url":"https://api.github.com/orgs/Testably/members{/member}","public_members_url":"https://api.github.com/orgs/Testably/public_members{/member}","avatar_url":"https://avatars.githubusercontent.com/u/113782592?v=4","description":""},"sender":{"login":"vbreuss","id":3438234,"node_id":"MDQ6VXNlcjM0MzgyMzQ=","avatar_url":"https://avatars.githubusercontent.com/u/3438234?v=4","gravatar_id":"","url":"https://api.github.com/users/vbreuss","html_url":"https://github.com/vbreuss","followers_url":"https://api.github.com/users/vbreuss/followers","following_url":"https://api.github.com/users/vbreuss/following{/other_user}","gists_url":"https://api.github.com/users/vbreuss/gists{/gist_id}","starred_url":"https://api.github.com/users/vbreuss/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vbreuss/subscriptions","organizations_url":"https://api.github.com/users/vbreuss/orgs","repos_url":"https://api.github.com/users/vbreuss/repos","events_url":"https://api.github.com/users/vbreuss/events{/privacy}","received_events_url":"https://api.github.com/users/vbreuss/received_events","type":"User","site_admin":false}} + """; + var githubResponse = + $$$""" + {"url":"https://api.github.com/repos/Testably/Testably.Server/pulls/1","id":1798848450,"node_id":"PR_kwDOLne9u85rOD_C","html_url":"https://github.com/Testably/Testably.Server/pull/1","diff_url":"https://github.com/Testably/Testably.Server/pull/1.diff","patch_url":"https://github.com/Testably/Testably.Server/pull/1.patch","issue_url":"https://api.github.com/repos/Testably/Testably.Server/issues/1","number":1,"state":"open","locked":false,"title":"{{{title}}}","user":{"login":"vbreuss","id":3438234,"node_id":"MDQ6VXNlcjM0MzgyMzQ=","avatar_url":"https://avatars.githubusercontent.com/u/3438234?v=4","gravatar_id":"","url":"https://api.github.com/users/vbreuss","html_url":"https://github.com/vbreuss","followers_url":"https://api.github.com/users/vbreuss/followers","following_url":"https://api.github.com/users/vbreuss/following{/other_user}","gists_url":"https://api.github.com/users/vbreuss/gists{/gist_id}","starred_url":"https://api.github.com/users/vbreuss/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vbreuss/subscriptions","organizations_url":"https://api.github.com/users/vbreuss/orgs","repos_url":"https://api.github.com/users/vbreuss/repos","events_url":"https://api.github.com/users/vbreuss/events{/privacy}","received_events_url":"https://api.github.com/users/vbreuss/received_events","type":"User","site_admin":false},"body":null,"created_at":"2024-03-30T09:40:30Z","updated_at":"2024-03-30T10:19:35Z","closed_at":null,"merged_at":null,"merge_commit_sha":"c58bf0ce4d7ed8a0c5efef05eb593e0ef5f2ec9e","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"draft":false,"commits_url":"https://api.github.com/repos/Testably/Testably.Server/pulls/1/commits","review_comments_url":"https://api.github.com/repos/Testably/Testably.Server/pulls/1/comments","review_comment_url":"https://api.github.com/repos/Testably/Testably.Server/pulls/comments{/number}","comments_url":"https://api.github.com/repos/Testably/Testably.Server/issues/1/comments","statuses_url":"https://api.github.com/repos/Testably/Testably.Server/statuses/21fca141f27cec38edf14c405c7413b3a3f6c6ed","head":{"label":"Testably:topic/add-initial-project","ref":"topic/add-initial-project","sha":"21fca141f27cec38edf14c405c7413b3a3f6c6ed","user":{"login":"Testably","id":113782592,"node_id":"O_kgDOBsgvQA","avatar_url":"https://avatars.githubusercontent.com/u/113782592?v=4","gravatar_id":"","url":"https://api.github.com/users/Testably","html_url":"https://github.com/Testably","followers_url":"https://api.github.com/users/Testably/followers","following_url":"https://api.github.com/users/Testably/following{/other_user}","gists_url":"https://api.github.com/users/Testably/gists{/gist_id}","starred_url":"https://api.github.com/users/Testably/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Testably/subscriptions","organizations_url":"https://api.github.com/users/Testably/orgs","repos_url":"https://api.github.com/users/Testably/repos","events_url":"https://api.github.com/users/Testably/events{/privacy}","received_events_url":"https://api.github.com/users/Testably/received_events","type":"Organization","site_admin":false},"repo":{"id":779599291,"node_id":"R_kgDOLne9uw","name":"Testably.Server","full_name":"Testably/Testably.Server","private":false,"owner":{"login":"Testably","id":113782592,"node_id":"O_kgDOBsgvQA","avatar_url":"https://avatars.githubusercontent.com/u/113782592?v=4","gravatar_id":"","url":"https://api.github.com/users/Testably","html_url":"https://github.com/Testably","followers_url":"https://api.github.com/users/Testably/followers","following_url":"https://api.github.com/users/Testably/following{/other_user}","gists_url":"https://api.github.com/users/Testably/gists{/gist_id}","starred_url":"https://api.github.com/users/Testably/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Testably/subscriptions","organizations_url":"https://api.github.com/users/Testably/orgs","repos_url":"https://api.github.com/users/Testably/repos","events_url":"https://api.github.com/users/Testably/events{/privacy}","received_events_url":"https://api.github.com/users/Testably/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/Testably/Testably.Server","description":"The server for the Testably projects.","fork":false,"url":"https://api.github.com/repos/Testably/Testably.Server","forks_url":"https://api.github.com/repos/Testably/Testably.Server/forks","keys_url":"https://api.github.com/repos/Testably/Testably.Server/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Testably/Testably.Server/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Testably/Testably.Server/teams","hooks_url":"https://api.github.com/repos/Testably/Testably.Server/hooks","issue_events_url":"https://api.github.com/repos/Testably/Testably.Server/issues/events{/number}","events_url":"https://api.github.com/repos/Testably/Testably.Server/events","assignees_url":"https://api.github.com/repos/Testably/Testably.Server/assignees{/user}","branches_url":"https://api.github.com/repos/Testably/Testably.Server/branches{/branch}","tags_url":"https://api.github.com/repos/Testably/Testably.Server/tags","blobs_url":"https://api.github.com/repos/Testably/Testably.Server/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Testably/Testably.Server/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Testably/Testably.Server/git/refs{/sha}","trees_url":"https://api.github.com/repos/Testably/Testably.Server/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Testably/Testably.Server/statuses/{sha}","languages_url":"https://api.github.com/repos/Testably/Testably.Server/languages","stargazers_url":"https://api.github.com/repos/Testably/Testably.Server/stargazers","contributors_url":"https://api.github.com/repos/Testably/Testably.Server/contributors","subscribers_url":"https://api.github.com/repos/Testably/Testably.Server/subscribers","subscription_url":"https://api.github.com/repos/Testably/Testably.Server/subscription","commits_url":"https://api.github.com/repos/Testably/Testably.Server/commits{/sha}","git_commits_url":"https://api.github.com/repos/Testably/Testably.Server/git/commits{/sha}","comments_url":"https://api.github.com/repos/Testably/Testably.Server/comments{/number}","issue_comment_url":"https://api.github.com/repos/Testably/Testably.Server/issues/comments{/number}","contents_url":"https://api.github.com/repos/Testably/Testably.Server/contents/{+path}","compare_url":"https://api.github.com/repos/Testably/Testably.Server/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Testably/Testably.Server/merges","archive_url":"https://api.github.com/repos/Testably/Testably.Server/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Testably/Testably.Server/downloads","issues_url":"https://api.github.com/repos/Testably/Testably.Server/issues{/number}","pulls_url":"https://api.github.com/repos/Testably/Testably.Server/pulls{/number}","milestones_url":"https://api.github.com/repos/Testably/Testably.Server/milestones{/number}","notifications_url":"https://api.github.com/repos/Testably/Testably.Server/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Testably/Testably.Server/labels{/name}","releases_url":"https://api.github.com/repos/Testably/Testably.Server/releases{/id}","deployments_url":"https://api.github.com/repos/Testably/Testably.Server/deployments","created_at":"2024-03-30T09:08:11Z","updated_at":"2024-03-30T10:16:47Z","pushed_at":"2024-03-30T09:40:31Z","git_url":"git://github.com/Testably/Testably.Server.git","ssh_url":"git@github.com:Testably/Testably.Server.git","clone_url":"https://github.com/Testably/Testably.Server.git","svn_url":"https://github.com/Testably/Testably.Server","homepage":"","size":17,"stargazers_count":0,"watchers_count":0,"language":null,"has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"has_discussions":false,"forks_count":0,"mirror_url":null,"archived":false,"disabled":false,"open_issues_count":1,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit","node_id":"MDc6TGljZW5zZTEz"},"allow_forking":true,"is_template":false,"web_commit_signoff_required":false,"topics":[],"visibility":"public","forks":0,"open_issues":1,"watchers":0,"default_branch":"main"}},"base":{"label":"Testably:main","ref":"main","sha":"2a08a4ac7915f896c25838fab56c8711e6dd2220","user":{"login":"Testably","id":113782592,"node_id":"O_kgDOBsgvQA","avatar_url":"https://avatars.githubusercontent.com/u/113782592?v=4","gravatar_id":"","url":"https://api.github.com/users/Testably","html_url":"https://github.com/Testably","followers_url":"https://api.github.com/users/Testably/followers","following_url":"https://api.github.com/users/Testably/following{/other_user}","gists_url":"https://api.github.com/users/Testably/gists{/gist_id}","starred_url":"https://api.github.com/users/Testably/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Testably/subscriptions","organizations_url":"https://api.github.com/users/Testably/orgs","repos_url":"https://api.github.com/users/Testably/repos","events_url":"https://api.github.com/users/Testably/events{/privacy}","received_events_url":"https://api.github.com/users/Testably/received_events","type":"Organization","site_admin":false},"repo":{"id":779599291,"node_id":"R_kgDOLne9uw","name":"Testably.Server","full_name":"Testably/Testably.Server","private":false,"owner":{"login":"Testably","id":113782592,"node_id":"O_kgDOBsgvQA","avatar_url":"https://avatars.githubusercontent.com/u/113782592?v=4","gravatar_id":"","url":"https://api.github.com/users/Testably","html_url":"https://github.com/Testably","followers_url":"https://api.github.com/users/Testably/followers","following_url":"https://api.github.com/users/Testably/following{/other_user}","gists_url":"https://api.github.com/users/Testably/gists{/gist_id}","starred_url":"https://api.github.com/users/Testably/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Testably/subscriptions","organizations_url":"https://api.github.com/users/Testably/orgs","repos_url":"https://api.github.com/users/Testably/repos","events_url":"https://api.github.com/users/Testably/events{/privacy}","received_events_url":"https://api.github.com/users/Testably/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/Testably/Testably.Server","description":"The server for the Testably projects.","fork":false,"url":"https://api.github.com/repos/Testably/Testably.Server","forks_url":"https://api.github.com/repos/Testably/Testably.Server/forks","keys_url":"https://api.github.com/repos/Testably/Testably.Server/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Testably/Testably.Server/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Testably/Testably.Server/teams","hooks_url":"https://api.github.com/repos/Testably/Testably.Server/hooks","issue_events_url":"https://api.github.com/repos/Testably/Testably.Server/issues/events{/number}","events_url":"https://api.github.com/repos/Testably/Testably.Server/events","assignees_url":"https://api.github.com/repos/Testably/Testably.Server/assignees{/user}","branches_url":"https://api.github.com/repos/Testably/Testably.Server/branches{/branch}","tags_url":"https://api.github.com/repos/Testably/Testably.Server/tags","blobs_url":"https://api.github.com/repos/Testably/Testably.Server/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Testably/Testably.Server/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Testably/Testably.Server/git/refs{/sha}","trees_url":"https://api.github.com/repos/Testably/Testably.Server/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Testably/Testably.Server/statuses/{sha}","languages_url":"https://api.github.com/repos/Testably/Testably.Server/languages","stargazers_url":"https://api.github.com/repos/Testably/Testably.Server/stargazers","contributors_url":"https://api.github.com/repos/Testably/Testably.Server/contributors","subscribers_url":"https://api.github.com/repos/Testably/Testably.Server/subscribers","subscription_url":"https://api.github.com/repos/Testably/Testably.Server/subscription","commits_url":"https://api.github.com/repos/Testably/Testably.Server/commits{/sha}","git_commits_url":"https://api.github.com/repos/Testably/Testably.Server/git/commits{/sha}","comments_url":"https://api.github.com/repos/Testably/Testably.Server/comments{/number}","issue_comment_url":"https://api.github.com/repos/Testably/Testably.Server/issues/comments{/number}","contents_url":"https://api.github.com/repos/Testably/Testably.Server/contents/{+path}","compare_url":"https://api.github.com/repos/Testably/Testably.Server/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Testably/Testably.Server/merges","archive_url":"https://api.github.com/repos/Testably/Testably.Server/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Testably/Testably.Server/downloads","issues_url":"https://api.github.com/repos/Testably/Testably.Server/issues{/number}","pulls_url":"https://api.github.com/repos/Testably/Testably.Server/pulls{/number}","milestones_url":"https://api.github.com/repos/Testably/Testably.Server/milestones{/number}","notifications_url":"https://api.github.com/repos/Testably/Testably.Server/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Testably/Testably.Server/labels{/name}","releases_url":"https://api.github.com/repos/Testably/Testably.Server/releases{/id}","deployments_url":"https://api.github.com/repos/Testably/Testably.Server/deployments","created_at":"2024-03-30T09:08:11Z","updated_at":"2024-03-30T10:16:47Z","pushed_at":"2024-03-30T09:40:31Z","git_url":"git://github.com/Testably/Testably.Server.git","ssh_url":"git@github.com:Testably/Testably.Server.git","clone_url":"https://github.com/Testably/Testably.Server.git","svn_url":"https://github.com/Testably/Testably.Server","homepage":"","size":17,"stargazers_count":0,"watchers_count":0,"language":null,"has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"has_discussions":false,"forks_count":0,"mirror_url":null,"archived":false,"disabled":false,"open_issues_count":1,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit","node_id":"MDc6TGljZW5zZTEz"},"allow_forking":true,"is_template":false,"web_commit_signoff_required":false,"topics":[],"visibility":"public","forks":0,"open_issues":1,"watchers":0,"default_branch":"main"}},"_links":{"self":{"href":"https://api.github.com/repos/Testably/Testably.Server/pulls/1"},"html":{"href":"https://github.com/Testably/Testably.Server/pull/1"},"issue":{"href":"https://api.github.com/repos/Testably/Testably.Server/issues/1"},"comments":{"href":"https://api.github.com/repos/Testably/Testably.Server/issues/1/comments"},"review_comments":{"href":"https://api.github.com/repos/Testably/Testably.Server/pulls/1/comments"},"review_comment":{"href":"https://api.github.com/repos/Testably/Testably.Server/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/Testably/Testably.Server/pulls/1/commits"},"statuses":{"href":"https://api.github.com/repos/Testably/Testably.Server/statuses/21fca141f27cec38edf14c405c7413b3a3f6c6ed"}},"author_association":"MEMBER","auto_merge":null,"active_lock_reason":null,"merged":false,"mergeable":true,"rebaseable":true,"mergeable_state":"clean","merged_by":null,"comments":0,"review_comments":0,"maintainer_can_modify":false,"commits":1,"additions":897,"deletions":0,"changed_files":23} + """; + string? sentStatusCheck = null; + var httpClientFactoryMock = MockHttpClientFactory(( + r => r.Method == HttpMethod.Get && r.RequestUri!.AbsoluteUri.StartsWith( + "https://api.github.com/repos/Testably/Testably.Server/pulls/1"), + _ => githubResponse), + ( + r => r.Method == HttpMethod.Post && r.RequestUri!.AbsoluteUri.StartsWith( + "https://api.github.com/repos/Testably/Testably.Server/statuses"), + c => + { + sentStatusCheck = c; + return ""; + })); + await using var factory = new TestFactory(httpClientFactoryMock.Object); + using var client = factory.CreateClient(); + client.DefaultRequestHeaders.Add("x-github-event", "pull_request"); + using var content = new StringContent(webhookPayload, mediaType: "application/json", + encoding: Encoding.UTF8); - var response = await client.PostAsync("pr-status-check", content); - response.EnsureSuccessStatusCode(); + var response = await client.PostAsync("pr-status-check", content); + response.EnsureSuccessStatusCode(); - Assert.Contains($"\"state\":\"{status}\"", sentStatusCheck); - } + Assert.Contains($"\"state\":\"{status}\"", sentStatusCheck); + } - #region Helpers + #region Helpers - public static string? GetRequestBody(HttpRequestMessage message) - { - if (message.Content == null) - { - return null; - } + public static string? GetRequestBody(HttpRequestMessage message) + { + if (message.Content == null) + { + return null; + } - var bodyStream = new StreamReader(message.Content.ReadAsStream()); - return bodyStream.ReadToEnd(); - } + var bodyStream = new StreamReader(message.Content.ReadAsStream()); + return bodyStream.ReadToEnd(); + } - private static Mock MockHttpClientFactory( - params (Func, Func)[] responses) - { - var mockHttpMessageHandler = new Mock(); - foreach (var response in responses) - { - mockHttpMessageHandler.Protected() - .Setup>( - "SendAsync", - ItExpr.Is(r => response.Item1(r)), - ItExpr.IsAny() - ) - .ReturnsAsync((HttpRequestMessage m, CancellationToken _) - => new HttpResponseMessage(HttpStatusCode.OK) - { - Content = new StringContent(response.Item2(GetRequestBody(m))) - }); - } + private static Mock MockHttpClientFactory( + params (Func, Func)[] responses) + { + var mockHttpMessageHandler = new Mock(); + foreach (var response in responses) + { + mockHttpMessageHandler.Protected() + .Setup>( + "SendAsync", + ItExpr.Is(r => response.Item1(r)), + ItExpr.IsAny() + ) + .ReturnsAsync((HttpRequestMessage m, CancellationToken _) + => new HttpResponseMessage(HttpStatusCode.OK) + { + Content = new StringContent(response.Item2(GetRequestBody(m))) + }); + } - var httpClientFactoryMock = new Mock(); - httpClientFactoryMock.Setup(m => m.CreateClient(It.IsAny())) - .Returns(new HttpClient(mockHttpMessageHandler.Object)); - return httpClientFactoryMock; - } + var httpClientFactoryMock = new Mock(); + httpClientFactoryMock.Setup(m => m.CreateClient(It.IsAny())) + .Returns(new HttpClient(mockHttpMessageHandler.Object)); + return httpClientFactoryMock; + } - #endregion + #endregion } \ No newline at end of file