Fix invalid category test

This commit is contained in:
Liam Newman
2021-06-14 13:11:10 -07:00
parent 3eb2e13a6d
commit f7f626a00c
6 changed files with 329 additions and 14 deletions

View File

@@ -2,8 +2,6 @@ package org.kohsuke.github;
import org.junit.Test;
import java.util.UUID;
import static org.hamcrest.Matchers.*;
import static org.junit.Assert.assertThrows;
@@ -15,10 +13,9 @@ public class GHReleaseTest extends AbstractGitHubWireMockTest {
String tagName = mockGitHub.getMethodName();
GHRelease release = repo.createRelease(tagName).categoryName("announcements").prerelease(false).create();
GHRelease releaseCheck = repo.getRelease(release.getId());
try {
GHRelease releaseCheck = repo.getRelease(release.getId());
assertThat(releaseCheck, notNullValue());
assertThat(releaseCheck.getTagName(), is(tagName));
assertThat(releaseCheck.isPrerelease(), is(false));
@@ -36,9 +33,9 @@ public class GHReleaseTest extends AbstractGitHubWireMockTest {
String tagName = mockGitHub.getMethodName();
GHRelease release = repo.createRelease(tagName).create();
GHRelease releaseCheck = repo.getRelease(release.getId());
try {
GHRelease releaseCheck = repo.getRelease(release.getId());
assertThat(releaseCheck, notNullValue());
assertThat(releaseCheck.getTagName(), is(tagName));
assertThat(releaseCheck.getDiscussionUrl(), nullValue());
@@ -75,7 +72,7 @@ public class GHReleaseTest extends AbstractGitHubWireMockTest {
public void testCreateReleaseWithUnknownCategoryFails() throws Exception {
GHRepository repo = gitHub.getRepository("hub4j-test-org/testCreateRelease");
String tagName = UUID.randomUUID().toString();
String tagName = mockGitHub.getMethodName();
String releaseName = "release-" + tagName;
assertThrows(GHFileNotFoundException.class, () -> {
@@ -93,11 +90,10 @@ public class GHReleaseTest extends AbstractGitHubWireMockTest {
String tagName = mockGitHub.getMethodName();
GHRelease release = repo.createRelease(tagName).prerelease(true).create();
GHRelease releaseCheck = repo.getRelease(release.getId());
GHRelease updateCheck = releaseCheck.update().categoryName("announcements").prerelease(false).update();
try {
GHRelease releaseCheck = repo.getRelease(release.getId());
GHRelease updateCheck = releaseCheck.update().categoryName("announcements").prerelease(false).update();
assertThat(releaseCheck, notNullValue());
assertThat(releaseCheck.getTagName(), is(tagName));
assertThat(releaseCheck.isPrerelease(), is(true));
@@ -110,8 +106,7 @@ public class GHReleaseTest extends AbstractGitHubWireMockTest {
} finally {
release.delete();
assertThat(repo.getRelease(releaseCheck.getId()), nullValue());
assertThat(repo.getRelease(updateCheck.getId()), nullValue());
assertThat(repo.getRelease(release.getId()), nullValue());
}
}

View File

@@ -0,0 +1,132 @@
{
"id": 375534019,
"node_id": "MDEwOlJlcG9zaXRvcnkzNzU1MzQwMTk=",
"name": "testCreateRelease",
"full_name": "hub4j-test-org/testCreateRelease",
"private": false,
"owner": {
"login": "hub4j-test-org",
"id": 7544739,
"node_id": "MDEyOk9yZ2FuaXphdGlvbjc1NDQ3Mzk=",
"avatar_url": "https://avatars.githubusercontent.com/u/7544739?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/hub4j-test-org",
"html_url": "https://github.com/hub4j-test-org",
"followers_url": "https://api.github.com/users/hub4j-test-org/followers",
"following_url": "https://api.github.com/users/hub4j-test-org/following{/other_user}",
"gists_url": "https://api.github.com/users/hub4j-test-org/gists{/gist_id}",
"starred_url": "https://api.github.com/users/hub4j-test-org/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/hub4j-test-org/subscriptions",
"organizations_url": "https://api.github.com/users/hub4j-test-org/orgs",
"repos_url": "https://api.github.com/users/hub4j-test-org/repos",
"events_url": "https://api.github.com/users/hub4j-test-org/events{/privacy}",
"received_events_url": "https://api.github.com/users/hub4j-test-org/received_events",
"type": "Organization",
"site_admin": false
},
"html_url": "https://github.com/hub4j-test-org/testCreateRelease",
"description": null,
"fork": false,
"url": "https://api.github.com/repos/hub4j-test-org/testCreateRelease",
"forks_url": "https://api.github.com/repos/hub4j-test-org/testCreateRelease/forks",
"keys_url": "https://api.github.com/repos/hub4j-test-org/testCreateRelease/keys{/key_id}",
"collaborators_url": "https://api.github.com/repos/hub4j-test-org/testCreateRelease/collaborators{/collaborator}",
"teams_url": "https://api.github.com/repos/hub4j-test-org/testCreateRelease/teams",
"hooks_url": "https://api.github.com/repos/hub4j-test-org/testCreateRelease/hooks",
"issue_events_url": "https://api.github.com/repos/hub4j-test-org/testCreateRelease/issues/events{/number}",
"events_url": "https://api.github.com/repos/hub4j-test-org/testCreateRelease/events",
"assignees_url": "https://api.github.com/repos/hub4j-test-org/testCreateRelease/assignees{/user}",
"branches_url": "https://api.github.com/repos/hub4j-test-org/testCreateRelease/branches{/branch}",
"tags_url": "https://api.github.com/repos/hub4j-test-org/testCreateRelease/tags",
"blobs_url": "https://api.github.com/repos/hub4j-test-org/testCreateRelease/git/blobs{/sha}",
"git_tags_url": "https://api.github.com/repos/hub4j-test-org/testCreateRelease/git/tags{/sha}",
"git_refs_url": "https://api.github.com/repos/hub4j-test-org/testCreateRelease/git/refs{/sha}",
"trees_url": "https://api.github.com/repos/hub4j-test-org/testCreateRelease/git/trees{/sha}",
"statuses_url": "https://api.github.com/repos/hub4j-test-org/testCreateRelease/statuses/{sha}",
"languages_url": "https://api.github.com/repos/hub4j-test-org/testCreateRelease/languages",
"stargazers_url": "https://api.github.com/repos/hub4j-test-org/testCreateRelease/stargazers",
"contributors_url": "https://api.github.com/repos/hub4j-test-org/testCreateRelease/contributors",
"subscribers_url": "https://api.github.com/repos/hub4j-test-org/testCreateRelease/subscribers",
"subscription_url": "https://api.github.com/repos/hub4j-test-org/testCreateRelease/subscription",
"commits_url": "https://api.github.com/repos/hub4j-test-org/testCreateRelease/commits{/sha}",
"git_commits_url": "https://api.github.com/repos/hub4j-test-org/testCreateRelease/git/commits{/sha}",
"comments_url": "https://api.github.com/repos/hub4j-test-org/testCreateRelease/comments{/number}",
"issue_comment_url": "https://api.github.com/repos/hub4j-test-org/testCreateRelease/issues/comments{/number}",
"contents_url": "https://api.github.com/repos/hub4j-test-org/testCreateRelease/contents/{+path}",
"compare_url": "https://api.github.com/repos/hub4j-test-org/testCreateRelease/compare/{base}...{head}",
"merges_url": "https://api.github.com/repos/hub4j-test-org/testCreateRelease/merges",
"archive_url": "https://api.github.com/repos/hub4j-test-org/testCreateRelease/{archive_format}{/ref}",
"downloads_url": "https://api.github.com/repos/hub4j-test-org/testCreateRelease/downloads",
"issues_url": "https://api.github.com/repos/hub4j-test-org/testCreateRelease/issues{/number}",
"pulls_url": "https://api.github.com/repos/hub4j-test-org/testCreateRelease/pulls{/number}",
"milestones_url": "https://api.github.com/repos/hub4j-test-org/testCreateRelease/milestones{/number}",
"notifications_url": "https://api.github.com/repos/hub4j-test-org/testCreateRelease/notifications{?since,all,participating}",
"labels_url": "https://api.github.com/repos/hub4j-test-org/testCreateRelease/labels{/name}",
"releases_url": "https://api.github.com/repos/hub4j-test-org/testCreateRelease/releases{/id}",
"deployments_url": "https://api.github.com/repos/hub4j-test-org/testCreateRelease/deployments",
"created_at": "2021-06-10T01:25:59Z",
"updated_at": "2021-06-10T01:31:14Z",
"pushed_at": "2021-06-14T20:03:30Z",
"git_url": "git://github.com/hub4j-test-org/testCreateRelease.git",
"ssh_url": "git@github.com:hub4j-test-org/testCreateRelease.git",
"clone_url": "https://github.com/hub4j-test-org/testCreateRelease.git",
"svn_url": "https://github.com/hub4j-test-org/testCreateRelease",
"homepage": null,
"size": 11948,
"stargazers_count": 0,
"watchers_count": 0,
"language": "Java",
"has_issues": false,
"has_projects": false,
"has_downloads": true,
"has_wiki": false,
"has_pages": false,
"forks_count": 0,
"mirror_url": null,
"archived": false,
"disabled": false,
"open_issues_count": 0,
"license": {
"key": "mit",
"name": "MIT License",
"spdx_id": "MIT",
"url": "https://api.github.com/licenses/mit",
"node_id": "MDc6TGljZW5zZTEz"
},
"forks": 0,
"open_issues": 0,
"watchers": 0,
"default_branch": "main",
"permissions": {
"admin": true,
"push": true,
"pull": true
},
"temp_clone_token": "",
"allow_squash_merge": true,
"allow_merge_commit": true,
"allow_rebase_merge": true,
"delete_branch_on_merge": false,
"organization": {
"login": "hub4j-test-org",
"id": 7544739,
"node_id": "MDEyOk9yZ2FuaXphdGlvbjc1NDQ3Mzk=",
"avatar_url": "https://avatars.githubusercontent.com/u/7544739?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/hub4j-test-org",
"html_url": "https://github.com/hub4j-test-org",
"followers_url": "https://api.github.com/users/hub4j-test-org/followers",
"following_url": "https://api.github.com/users/hub4j-test-org/following{/other_user}",
"gists_url": "https://api.github.com/users/hub4j-test-org/gists{/gist_id}",
"starred_url": "https://api.github.com/users/hub4j-test-org/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/hub4j-test-org/subscriptions",
"organizations_url": "https://api.github.com/users/hub4j-test-org/orgs",
"repos_url": "https://api.github.com/users/hub4j-test-org/repos",
"events_url": "https://api.github.com/users/hub4j-test-org/events{/privacy}",
"received_events_url": "https://api.github.com/users/hub4j-test-org/received_events",
"type": "Organization",
"site_admin": false
},
"network_count": 0,
"subscribers_count": 11
}

View File

@@ -0,0 +1,46 @@
{
"login": "bitwiseman",
"id": 1958953,
"node_id": "MDQ6VXNlcjE5NTg5NTM=",
"avatar_url": "https://avatars.githubusercontent.com/u/1958953?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/bitwiseman",
"html_url": "https://github.com/bitwiseman",
"followers_url": "https://api.github.com/users/bitwiseman/followers",
"following_url": "https://api.github.com/users/bitwiseman/following{/other_user}",
"gists_url": "https://api.github.com/users/bitwiseman/gists{/gist_id}",
"starred_url": "https://api.github.com/users/bitwiseman/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/bitwiseman/subscriptions",
"organizations_url": "https://api.github.com/users/bitwiseman/orgs",
"repos_url": "https://api.github.com/users/bitwiseman/repos",
"events_url": "https://api.github.com/users/bitwiseman/events{/privacy}",
"received_events_url": "https://api.github.com/users/bitwiseman/received_events",
"type": "User",
"site_admin": false,
"name": "Liam Newman",
"company": "Cloudbees, Inc.",
"blog": "",
"location": "Seattle, WA, USA",
"email": "bitwiseman@gmail.com",
"hireable": null,
"bio": null,
"twitter_username": "bitwiseman",
"public_repos": 209,
"public_gists": 8,
"followers": 187,
"following": 12,
"created_at": "2012-07-11T20:38:33Z",
"updated_at": "2021-06-14T20:00:35Z",
"private_gists": 19,
"total_private_repos": 21,
"owned_private_repos": 0,
"disk_usage": 33700,
"collaborators": 0,
"two_factor_authentication": true,
"plan": {
"name": "free",
"space": 976562499,
"collaborators": 0,
"private_repos": 10000
}
}

View File

@@ -0,0 +1,47 @@
{
"id": "467b7a17-b090-4498-a03e-428f78110f2d",
"name": "repos_hub4j-test-org_testcreaterelease",
"request": {
"url": "/repos/hub4j-test-org/testCreateRelease",
"method": "GET",
"headers": {
"Accept": {
"equalTo": "text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2"
}
}
},
"response": {
"status": 200,
"bodyFileName": "repos_hub4j-test-org_testcreaterelease-2.json",
"headers": {
"Server": "GitHub.com",
"Date": "Mon, 14 Jun 2021 20:07:53 GMT",
"Content-Type": "application/json; charset=utf-8",
"Cache-Control": "private, max-age=60, s-maxage=60",
"Vary": [
"Accept, Authorization, Cookie, X-GitHub-OTP",
"Accept-Encoding, Accept, X-Requested-With"
],
"ETag": "W/\"32a66bfea0e2a70e2dc6c6616328f0abbea8bbc5fb6977d402c6832f472e15a7\"",
"Last-Modified": "Thu, 10 Jun 2021 01:31:14 GMT",
"X-OAuth-Scopes": "admin:org, admin:org_hook, admin:public_key, admin:repo_hook, delete_repo, gist, notifications, repo, user, workflow, write:discussion",
"X-Accepted-OAuth-Scopes": "repo",
"X-GitHub-Media-Type": "unknown, github.v3",
"X-RateLimit-Limit": "5000",
"X-RateLimit-Remaining": "4925",
"X-RateLimit-Reset": "1623701637",
"X-RateLimit-Used": "75",
"X-RateLimit-Resource": "core",
"Strict-Transport-Security": "max-age=31536000; includeSubdomains; preload",
"X-Frame-Options": "deny",
"X-Content-Type-Options": "nosniff",
"X-XSS-Protection": "0",
"Referrer-Policy": "origin-when-cross-origin, strict-origin-when-cross-origin",
"Content-Security-Policy": "default-src 'none'",
"X-GitHub-Request-Id": "F69E:0CE1:2ECAB7:3EA336:60C7B719"
}
},
"uuid": "467b7a17-b090-4498-a03e-428f78110f2d",
"persistent": true,
"insertionIndex": 2
}

View File

@@ -0,0 +1,48 @@
{
"id": "78307b46-4de1-4554-a60f-d2285eaf5ab8",
"name": "repos_hub4j-test-org_testcreaterelease_releases",
"request": {
"url": "/repos/hub4j-test-org/testCreateRelease/releases",
"method": "POST",
"headers": {
"Accept": {
"equalTo": "text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2"
}
},
"bodyPatterns": [
{
"equalToJson": "{\"discussion_category_name\":\"an invalid cateogry\",\"tag_name\":\"testCreateReleaseWithUnknownCategoryFails\",\"prerelease\":false,\"name\":\"release-testCreateReleaseWithUnknownCategoryFails\"}",
"ignoreArrayOrder": true,
"ignoreExtraElements": false
}
]
},
"response": {
"status": 404,
"body": "{\"message\":\"Discussion could not be created. Make sure you passed a valid category name.\",\"documentation_url\":\"https://docs.github.com/rest/reference/repos#create-a-release\"}",
"headers": {
"Server": "GitHub.com",
"Date": "Mon, 14 Jun 2021 20:07:53 GMT",
"Content-Type": "application/json; charset=utf-8",
"X-OAuth-Scopes": "admin:org, admin:org_hook, admin:public_key, admin:repo_hook, delete_repo, gist, notifications, repo, user, workflow, write:discussion",
"X-Accepted-OAuth-Scopes": "repo",
"X-GitHub-Media-Type": "unknown, github.v3",
"X-RateLimit-Limit": "5000",
"X-RateLimit-Remaining": "4924",
"X-RateLimit-Reset": "1623701637",
"X-RateLimit-Used": "76",
"X-RateLimit-Resource": "core",
"Strict-Transport-Security": "max-age=31536000; includeSubdomains; preload",
"X-Frame-Options": "deny",
"X-Content-Type-Options": "nosniff",
"X-XSS-Protection": "0",
"Referrer-Policy": "origin-when-cross-origin, strict-origin-when-cross-origin",
"Content-Security-Policy": "default-src 'none'",
"Vary": "Accept-Encoding, Accept, X-Requested-With",
"X-GitHub-Request-Id": "F6A0:0CE8:71F565:825F84:60C7B719"
}
},
"uuid": "78307b46-4de1-4554-a60f-d2285eaf5ab8",
"persistent": true,
"insertionIndex": 3
}

View File

@@ -0,0 +1,47 @@
{
"id": "b410b598-fc14-48cc-8e39-1277b3df0846",
"name": "user",
"request": {
"url": "/user",
"method": "GET",
"headers": {
"Accept": {
"equalTo": "text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2"
}
}
},
"response": {
"status": 200,
"bodyFileName": "user-1.json",
"headers": {
"Server": "GitHub.com",
"Date": "Mon, 14 Jun 2021 20:07:52 GMT",
"Content-Type": "application/json; charset=utf-8",
"Cache-Control": "private, max-age=60, s-maxage=60",
"Vary": [
"Accept, Authorization, Cookie, X-GitHub-OTP",
"Accept-Encoding, Accept, X-Requested-With"
],
"ETag": "W/\"c1e456100f9b085b8b6a8fc43a8973a0aa267ed9d24814f8e51a312db9835a71\"",
"Last-Modified": "Mon, 14 Jun 2021 20:00:35 GMT",
"X-OAuth-Scopes": "admin:org, admin:org_hook, admin:public_key, admin:repo_hook, delete_repo, gist, notifications, repo, user, workflow, write:discussion",
"X-Accepted-OAuth-Scopes": "",
"X-GitHub-Media-Type": "unknown, github.v3",
"X-RateLimit-Limit": "5000",
"X-RateLimit-Remaining": "4927",
"X-RateLimit-Reset": "1623701637",
"X-RateLimit-Used": "73",
"X-RateLimit-Resource": "core",
"Strict-Transport-Security": "max-age=31536000; includeSubdomains; preload",
"X-Frame-Options": "deny",
"X-Content-Type-Options": "nosniff",
"X-XSS-Protection": "0",
"Referrer-Policy": "origin-when-cross-origin, strict-origin-when-cross-origin",
"Content-Security-Policy": "default-src 'none'",
"X-GitHub-Request-Id": "F69A:0D59:E2AB80:F2F137:60C7B718"
}
},
"uuid": "b410b598-fc14-48cc-8e39-1277b3df0846",
"persistent": true,
"insertionIndex": 1
}