Move to own test class

This commit is contained in:
Julien Lengrand-Lambert
2021-06-10 17:53:56 +02:00
parent 5b07a5e012
commit 86963d7adb
10 changed files with 104 additions and 72 deletions

View File

@@ -777,22 +777,6 @@ public class AppTest extends AbstractGitHubWireMockTest {
assertThat(j.hasPublicMember(b), is(false));
}
@Test
public void testCreateSimpleRelease() throws Exception {
GHRepository repo = gitHub.getRepository("hub4j-test-org/testCreateRelease");
String tagName = UUID.randomUUID().toString();
String releaseName = "release-" + tagName;
GHRelease release = repo.createRelease(tagName).name(releaseName).prerelease(false).create();
GHRelease releaseCheck = repo.getRelease(release.getId());
assertThat(releaseCheck, notNullValue());
assertThat(releaseCheck.getTagName(), is(tagName));
assertThat(releaseCheck.isPrerelease(), is(false));
}
@Ignore("Needs mocking check")
@Test
public void testCreateRelease() throws Exception {

View File

@@ -0,0 +1,48 @@
package org.kohsuke.github;
import org.junit.Test;
import java.util.UUID;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.notNullValue;
public class ReleaseTest extends AbstractGitHubWireMockTest {
@Test
public void testCreateSimpleRelease() throws Exception {
GHRepository repo = gitHub.getRepository("hub4j-test-org/testCreateRelease");
String tagName = UUID.randomUUID().toString();
String releaseName = "release-" + tagName;
GHRelease release = repo.createRelease(tagName).name(releaseName).prerelease(false).create();
GHRelease releaseCheck = repo.getRelease(release.getId());
assertThat(releaseCheck, notNullValue());
assertThat(releaseCheck.getTagName(), is(tagName));
assertThat(releaseCheck.isPrerelease(), is(false));
}
@Test
public void testCreateDoubleRelease() throws Exception {
GHRepository repo = gitHub.getRepository("hub4j-test-org/testCreateRelease");
String tagName = UUID.randomUUID().toString();
String releaseName = "release-" + tagName;
GHRelease release = repo.createRelease(tagName).name(releaseName).create();
GHRelease releaseCheck = repo.getRelease(release.getId());
assertThat(releaseCheck, notNullValue());
try{
repo.createRelease(tagName).name(releaseName).create();
}
catch(HttpException e){
}
}
}

View File

@@ -66,7 +66,7 @@
"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-10T15:39:13Z",
"pushed_at": "2021-06-10T15:50:44Z",
"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",

View File

@@ -1,9 +1,9 @@
{
"url": "https://api.github.com/repos/hub4j-test-org/testCreateRelease/releases/44424367",
"assets_url": "https://api.github.com/repos/hub4j-test-org/testCreateRelease/releases/44424367/assets",
"upload_url": "https://uploads.github.com/repos/hub4j-test-org/testCreateRelease/releases/44424367/assets{?name,label}",
"html_url": "https://github.com/hub4j-test-org/testCreateRelease/releases/tag/8f928732-f833-4723-9e40-827209fde59d",
"id": 44424367,
"url": "https://api.github.com/repos/hub4j-test-org/testCreateRelease/releases/44425482",
"assets_url": "https://api.github.com/repos/hub4j-test-org/testCreateRelease/releases/44425482/assets",
"upload_url": "https://uploads.github.com/repos/hub4j-test-org/testCreateRelease/releases/44425482/assets{?name,label}",
"html_url": "https://github.com/hub4j-test-org/testCreateRelease/releases/tag/f9c2647a-6a65-47c5-9c46-4c0a3650ecb1",
"id": 44425482,
"author": {
"login": "jlengrand",
"id": 921666,
@@ -24,16 +24,16 @@
"type": "User",
"site_admin": false
},
"node_id": "MDc6UmVsZWFzZTQ0NDI0MzY3",
"tag_name": "8f928732-f833-4723-9e40-827209fde59d",
"node_id": "MDc6UmVsZWFzZTQ0NDI1NDgy",
"tag_name": "f9c2647a-6a65-47c5-9c46-4c0a3650ecb1",
"target_commitish": "main",
"name": "release-8f928732-f833-4723-9e40-827209fde59d",
"name": "release-f9c2647a-6a65-47c5-9c46-4c0a3650ecb1",
"draft": false,
"prerelease": false,
"created_at": "2021-06-02T21:59:14Z",
"published_at": "2021-06-10T15:39:41Z",
"published_at": "2021-06-10T15:53:21Z",
"assets": [],
"tarball_url": "https://api.github.com/repos/hub4j-test-org/testCreateRelease/tarball/8f928732-f833-4723-9e40-827209fde59d",
"zipball_url": "https://api.github.com/repos/hub4j-test-org/testCreateRelease/zipball/8f928732-f833-4723-9e40-827209fde59d",
"tarball_url": "https://api.github.com/repos/hub4j-test-org/testCreateRelease/tarball/f9c2647a-6a65-47c5-9c46-4c0a3650ecb1",
"zipball_url": "https://api.github.com/repos/hub4j-test-org/testCreateRelease/zipball/f9c2647a-6a65-47c5-9c46-4c0a3650ecb1",
"body": null
}

View File

@@ -1,9 +1,9 @@
{
"url": "https://api.github.com/repos/hub4j-test-org/testCreateRelease/releases/44424367",
"assets_url": "https://api.github.com/repos/hub4j-test-org/testCreateRelease/releases/44424367/assets",
"upload_url": "https://uploads.github.com/repos/hub4j-test-org/testCreateRelease/releases/44424367/assets{?name,label}",
"html_url": "https://github.com/hub4j-test-org/testCreateRelease/releases/tag/8f928732-f833-4723-9e40-827209fde59d",
"id": 44424367,
"url": "https://api.github.com/repos/hub4j-test-org/testCreateRelease/releases/44425482",
"assets_url": "https://api.github.com/repos/hub4j-test-org/testCreateRelease/releases/44425482/assets",
"upload_url": "https://uploads.github.com/repos/hub4j-test-org/testCreateRelease/releases/44425482/assets{?name,label}",
"html_url": "https://github.com/hub4j-test-org/testCreateRelease/releases/tag/f9c2647a-6a65-47c5-9c46-4c0a3650ecb1",
"id": 44425482,
"author": {
"login": "jlengrand",
"id": 921666,
@@ -24,16 +24,16 @@
"type": "User",
"site_admin": false
},
"node_id": "MDc6UmVsZWFzZTQ0NDI0MzY3",
"tag_name": "8f928732-f833-4723-9e40-827209fde59d",
"node_id": "MDc6UmVsZWFzZTQ0NDI1NDgy",
"tag_name": "f9c2647a-6a65-47c5-9c46-4c0a3650ecb1",
"target_commitish": "main",
"name": "release-8f928732-f833-4723-9e40-827209fde59d",
"name": "release-f9c2647a-6a65-47c5-9c46-4c0a3650ecb1",
"draft": false,
"prerelease": false,
"created_at": "2021-06-02T21:59:14Z",
"published_at": "2021-06-10T15:39:41Z",
"published_at": "2021-06-10T15:53:21Z",
"assets": [],
"tarball_url": "https://api.github.com/repos/hub4j-test-org/testCreateRelease/tarball/8f928732-f833-4723-9e40-827209fde59d",
"zipball_url": "https://api.github.com/repos/hub4j-test-org/testCreateRelease/zipball/8f928732-f833-4723-9e40-827209fde59d",
"tarball_url": "https://api.github.com/repos/hub4j-test-org/testCreateRelease/tarball/f9c2647a-6a65-47c5-9c46-4c0a3650ecb1",
"zipball_url": "https://api.github.com/repos/hub4j-test-org/testCreateRelease/zipball/f9c2647a-6a65-47c5-9c46-4c0a3650ecb1",
"body": null
}

View File

@@ -1,5 +1,5 @@
{
"id": "ac90e459-9122-4aa5-ad90-1a6ef39cbebe",
"id": "7cb5aa21-2b0d-4139-be8c-c12816556e50",
"name": "repos_hub4j-test-org_testcreaterelease",
"request": {
"url": "/repos/hub4j-test-org/testCreateRelease",
@@ -15,22 +15,22 @@
"bodyFileName": "repos_hub4j-test-org_testcreaterelease-2.json",
"headers": {
"Server": "GitHub.com",
"Date": "Thu, 10 Jun 2021 15:39:40 GMT",
"Date": "Thu, 10 Jun 2021 15:53:20 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/\"3f8afe97bec89cf81522e0cf7c16afc3615c3127914325e08a401a46a026059c\"",
"ETag": "W/\"f6c2944bb9667ef3a8e285429d3578819365ee57eca45b34f24b0260b3b5716a\"",
"Last-Modified": "Thu, 10 Jun 2021 01:31:14 GMT",
"X-OAuth-Scopes": "admin:enterprise, admin:gpg_key, admin:org, admin:org_hook, admin:public_key, admin:repo_hook, delete:packages, delete_repo, gist, notifications, repo, user, workflow, write:discussion, write:packages",
"X-Accepted-OAuth-Scopes": "repo",
"X-GitHub-Media-Type": "unknown, github.v3",
"X-RateLimit-Limit": "5000",
"X-RateLimit-Remaining": "4933",
"X-RateLimit-Remaining": "4917",
"X-RateLimit-Reset": "1623340890",
"X-RateLimit-Used": "67",
"X-RateLimit-Used": "83",
"X-RateLimit-Resource": "core",
"Strict-Transport-Security": "max-age=31536000; includeSubdomains; preload",
"X-Frame-Options": "deny",
@@ -38,10 +38,10 @@
"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": "C224:7AC1:25C29BD:26BF199:60C2323C"
"X-GitHub-Request-Id": "C2FC:9EEA:11C275E:1296C75:60C23570"
}
},
"uuid": "ac90e459-9122-4aa5-ad90-1a6ef39cbebe",
"uuid": "7cb5aa21-2b0d-4139-be8c-c12816556e50",
"persistent": true,
"insertionIndex": 2
}

View File

@@ -1,5 +1,5 @@
{
"id": "c72360f5-61f3-4439-b357-4402ac25601a",
"id": "1cdf46b2-2554-4f7c-b46f-334654200c77",
"name": "repos_hub4j-test-org_testcreaterelease_releases",
"request": {
"url": "/repos/hub4j-test-org/testCreateRelease/releases",
@@ -11,7 +11,7 @@
},
"bodyPatterns": [
{
"equalToJson": "{\"tag_name\":\"8f928732-f833-4723-9e40-827209fde59d\",\"prerelease\":false,\"name\":\"release-8f928732-f833-4723-9e40-827209fde59d\"}",
"equalToJson": "{\"tag_name\":\"f9c2647a-6a65-47c5-9c46-4c0a3650ecb1\",\"prerelease\":false,\"name\":\"release-f9c2647a-6a65-47c5-9c46-4c0a3650ecb1\"}",
"ignoreArrayOrder": true,
"ignoreExtraElements": false
}
@@ -22,21 +22,21 @@
"bodyFileName": "repos_hub4j-test-org_testcreaterelease_releases-3.json",
"headers": {
"Server": "GitHub.com",
"Date": "Thu, 10 Jun 2021 15:39:41 GMT",
"Date": "Thu, 10 Jun 2021 15:53:21 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": "\"b6d0f7b59c51608829f4a39bbbd968d53a79e44f96d8d5c2b8cbef387b7b9d06\"",
"ETag": "\"d04db25e3fb8db25df58ed0b5209b2697f2039213b0172674074fe6b83b6c9b1\"",
"X-OAuth-Scopes": "admin:enterprise, admin:gpg_key, admin:org, admin:org_hook, admin:public_key, admin:repo_hook, delete:packages, delete_repo, gist, notifications, repo, user, workflow, write:discussion, write:packages",
"X-Accepted-OAuth-Scopes": "repo",
"X-GitHub-Media-Type": "unknown, github.v3",
"X-RateLimit-Limit": "5000",
"X-RateLimit-Remaining": "4932",
"X-RateLimit-Remaining": "4916",
"X-RateLimit-Reset": "1623340890",
"X-RateLimit-Used": "68",
"X-RateLimit-Used": "84",
"X-RateLimit-Resource": "core",
"Strict-Transport-Security": "max-age=31536000; includeSubdomains; preload",
"X-Frame-Options": "deny",
@@ -44,11 +44,11 @@
"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": "C225:FE69:3DAFEED:3EE2EF0:60C2323D",
"Location": "https://api.github.com/repos/hub4j-test-org/testCreateRelease/releases/44424367"
"X-GitHub-Request-Id": "C2FD:A4AA:13BB58A:1491E71:60C23570",
"Location": "https://api.github.com/repos/hub4j-test-org/testCreateRelease/releases/44425482"
}
},
"uuid": "c72360f5-61f3-4439-b357-4402ac25601a",
"uuid": "1cdf46b2-2554-4f7c-b46f-334654200c77",
"persistent": true,
"insertionIndex": 3
}

View File

@@ -1,8 +1,8 @@
{
"id": "48b0e370-31b1-408c-8517-43935afb9f91",
"name": "repos_hub4j-test-org_testcreaterelease_releases_44424367",
"id": "f140dca7-efe5-4f61-b30a-8757621a8c07",
"name": "repos_hub4j-test-org_testcreaterelease_releases_44425482",
"request": {
"url": "/repos/hub4j-test-org/testCreateRelease/releases/44424367",
"url": "/repos/hub4j-test-org/testCreateRelease/releases/44425482",
"method": "GET",
"headers": {
"Accept": {
@@ -12,25 +12,25 @@
},
"response": {
"status": 200,
"bodyFileName": "repos_hub4j-test-org_testcreaterelease_releases_44424367-4.json",
"bodyFileName": "repos_hub4j-test-org_testcreaterelease_releases_44425482-4.json",
"headers": {
"Server": "GitHub.com",
"Date": "Thu, 10 Jun 2021 15:39:41 GMT",
"Date": "Thu, 10 Jun 2021 15:53:21 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/\"b6d0f7b59c51608829f4a39bbbd968d53a79e44f96d8d5c2b8cbef387b7b9d06\"",
"Last-Modified": "Thu, 10 Jun 2021 15:39:41 GMT",
"ETag": "W/\"d04db25e3fb8db25df58ed0b5209b2697f2039213b0172674074fe6b83b6c9b1\"",
"Last-Modified": "Thu, 10 Jun 2021 15:53:21 GMT",
"X-OAuth-Scopes": "admin:enterprise, admin:gpg_key, admin:org, admin:org_hook, admin:public_key, admin:repo_hook, delete:packages, delete_repo, gist, notifications, repo, user, workflow, write:discussion, write:packages",
"X-Accepted-OAuth-Scopes": "repo",
"X-GitHub-Media-Type": "unknown, github.v3",
"X-RateLimit-Limit": "5000",
"X-RateLimit-Remaining": "4931",
"X-RateLimit-Remaining": "4915",
"X-RateLimit-Reset": "1623340890",
"X-RateLimit-Used": "69",
"X-RateLimit-Used": "85",
"X-RateLimit-Resource": "core",
"Strict-Transport-Security": "max-age=31536000; includeSubdomains; preload",
"X-Frame-Options": "deny",
@@ -38,10 +38,10 @@
"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": "C226:9227:2513CAA:25CC456:60C2323D"
"X-GitHub-Request-Id": "C2FE:110C4:40DCEBE:42090F0:60C23571"
}
},
"uuid": "48b0e370-31b1-408c-8517-43935afb9f91",
"uuid": "f140dca7-efe5-4f61-b30a-8757621a8c07",
"persistent": true,
"insertionIndex": 4
}

View File

@@ -1,5 +1,5 @@
{
"id": "c1b5c491-edb4-4985-90b0-3b027fd3a6a7",
"id": "81ed97d4-3228-4db9-a444-4c1d0bbf9a90",
"name": "user",
"request": {
"url": "/user",
@@ -15,7 +15,7 @@
"bodyFileName": "user-1.json",
"headers": {
"Server": "GitHub.com",
"Date": "Thu, 10 Jun 2021 15:39:39 GMT",
"Date": "Thu, 10 Jun 2021 15:53:19 GMT",
"Content-Type": "application/json; charset=utf-8",
"Cache-Control": "private, max-age=60, s-maxage=60",
"Vary": [
@@ -28,9 +28,9 @@
"X-Accepted-OAuth-Scopes": "",
"X-GitHub-Media-Type": "unknown, github.v3",
"X-RateLimit-Limit": "5000",
"X-RateLimit-Remaining": "4935",
"X-RateLimit-Remaining": "4919",
"X-RateLimit-Reset": "1623340890",
"X-RateLimit-Used": "65",
"X-RateLimit-Used": "81",
"X-RateLimit-Resource": "core",
"Strict-Transport-Security": "max-age=31536000; includeSubdomains; preload",
"X-Frame-Options": "deny",
@@ -38,10 +38,10 @@
"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": "C222:E96D:4193E58:42C2987:60C2323B"
"X-GitHub-Request-Id": "C2FA:A130:31E6F41:32E5D39:60C2356F"
}
},
"uuid": "c1b5c491-edb4-4985-90b0-3b027fd3a6a7",
"uuid": "81ed97d4-3228-4db9-a444-4c1d0bbf9a90",
"persistent": true,
"insertionIndex": 1
}