Skip to content

Commit

Permalink
Add some assertions for GHWorkflow dispatch tests
Browse files Browse the repository at this point in the history
  • Loading branch information
gsmet committed Mar 25, 2021
1 parent 47e2a5a commit d734237
Show file tree
Hide file tree
Showing 26 changed files with 158 additions and 147 deletions.
15 changes: 13 additions & 2 deletions src/test/java/org/kohsuke/github/GHWorkflowTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@
import java.io.IOException;
import java.util.Collections;

import static com.github.tomakehurst.wiremock.client.WireMock.containing;
import static com.github.tomakehurst.wiremock.client.WireMock.postRequestedFor;
import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo;
import static com.github.tomakehurst.wiremock.client.WireMock.verify;

public class GHWorkflowTest extends AbstractGitHubWireMockTest {

private static String REPO_NAME = "hub4j-test-org/GHWorkflowTest";
Expand Down Expand Up @@ -71,8 +76,14 @@ public void testDispatch() throws IOException {
GHWorkflow workflow = repo.getWorkflow("test-workflow.yml");

workflow.dispatch("main");
workflow.dispatch("main", Collections.singletonMap("parameter", "value"));
verify(postRequestedFor(
urlPathEqualTo("/repos/hub4j-test-org/GHWorkflowTest/actions/workflows/6817859/dispatches")));

// if we implement the logs API at some point, it might be a good idea to validate all this
workflow.dispatch("main", Collections.singletonMap("parameter", "value"));
verify(postRequestedFor(
urlPathEqualTo("/repos/hub4j-test-org/GHWorkflowTest/actions/workflows/6817859/dispatches"))
.withRequestBody(containing("inputs"))
.withRequestBody(containing("parameter"))
.withRequestBody(containing("value")));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"path": ".github/workflows/test-workflow.yml",
"state": "active",
"created_at": "2021-03-17T10:33:32.000+01:00",
"updated_at": "2021-03-22T14:55:53.000+01:00",
"updated_at": "2021-03-25T11:36:24.000+01:00",
"url": "https://api.github.com/repos/hub4j-test-org/GHWorkflowTest/actions/workflows/6817859",
"html_url": "https://github.com/hub4j-test-org/GHWorkflowTest/blob/main/.github/workflows/test-workflow.yml",
"badge_url": "https://github.com/hub4j-test-org/GHWorkflowTest/workflows/test-workflow/badge.svg"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"path": ".github/workflows/test-workflow.yml",
"state": "active",
"created_at": "2021-03-17T10:33:32.000+01:00",
"updated_at": "2021-03-22T14:55:53.000+01:00",
"updated_at": "2021-03-25T11:36:24.000+01:00",
"url": "https://api.github.com/repos/hub4j-test-org/GHWorkflowTest/actions/workflows/6817859",
"html_url": "https://github.com/hub4j-test-org/GHWorkflowTest/blob/main/.github/workflows/test-workflow.yml",
"badge_url": "https://github.com/hub4j-test-org/GHWorkflowTest/workflows/test-workflow/badge.svg"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,16 @@
"hireable": null,
"bio": "Happy camper at Red Hat, working on Quarkus and the Hibernate portfolio.",
"twitter_username": "gsmet_",
"public_repos": 100,
"public_repos": 102,
"public_gists": 14,
"followers": 127,
"following": 3,
"created_at": "2011-12-22T11:03:22Z",
"updated_at": "2021-03-22T09:43:08Z",
"updated_at": "2021-03-23T17:35:45Z",
"private_gists": 14,
"total_private_repos": 5,
"owned_private_repos": 2,
"disk_usage": 68251,
"total_private_repos": 4,
"owned_private_repos": 1,
"disk_usage": 68258,
"collaborators": 1,
"two_factor_authentication": true,
"plan": {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"id": "c259c78e-7f1a-4379-bb5f-15851dc02172",
"id": "1fbf864b-587b-4d30-8a65-43dfecc97028",
"name": "repos_hub4j-test-org_ghworkflowtest",
"request": {
"url": "/repos/hub4j-test-org/GHWorkflowTest",
Expand All @@ -15,7 +15,7 @@
"bodyFileName": "repos_hub4j-test-org_ghworkflowtest-2.json",
"headers": {
"Server": "GitHub.com",
"Date": "Mon, 22 Mar 2021 13:55:57 GMT",
"Date": "Thu, 25 Mar 2021 10:36:28 GMT",
"Content-Type": "application/json; charset=utf-8",
"Cache-Control": "private, max-age=60, s-maxage=60",
"Vary": [
Expand All @@ -28,19 +28,19 @@
"X-Accepted-OAuth-Scopes": "repo",
"X-GitHub-Media-Type": "unknown, github.v3",
"X-RateLimit-Limit": "5000",
"X-RateLimit-Remaining": "4728",
"X-RateLimit-Reset": "1616422330",
"X-RateLimit-Used": "272",
"X-RateLimit-Remaining": "4973",
"X-RateLimit-Reset": "1616672182",
"X-RateLimit-Used": "27",
"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": "A79C:4909:5380D30:5593F68:6058A1ED"
"X-GitHub-Request-Id": "D5A4:4AE4:1010430:10B0B4D:605C67AC"
}
},
"uuid": "c259c78e-7f1a-4379-bb5f-15851dc02172",
"uuid": "1fbf864b-587b-4d30-8a65-43dfecc97028",
"persistent": true,
"insertionIndex": 2
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"id": "e6db7271-6997-4d05-8074-b0801c3070c3",
"id": "a37a5c44-61eb-4460-87e8-3207a15c7d2c",
"name": "repos_hub4j-test-org_ghworkflowtest_actions_workflows_6817859",
"request": {
"url": "/repos/hub4j-test-org/GHWorkflowTest/actions/workflows/6817859",
Expand All @@ -15,31 +15,31 @@
"bodyFileName": "repos_hub4j-test-org_ghworkflowtest_actions_workflows_6817859-4.json",
"headers": {
"Server": "GitHub.com",
"Date": "Mon, 22 Mar 2021 13:55:57 GMT",
"Date": "Thu, 25 Mar 2021 10:36:29 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/\"602070ef7b718d94b563e2480e6861839e193e0f9a3b1738f458c302da1d3083\"",
"ETag": "W/\"72a49555d2625ba9f490d619d324726f5192dc2a030dc22033b9cadf7a2ba076\"",
"X-OAuth-Scopes": "repo, user, workflow",
"X-Accepted-OAuth-Scopes": "",
"X-GitHub-Media-Type": "unknown, github.v3",
"X-RateLimit-Limit": "5000",
"X-RateLimit-Remaining": "4726",
"X-RateLimit-Reset": "1616422330",
"X-RateLimit-Used": "274",
"X-RateLimit-Remaining": "4971",
"X-RateLimit-Reset": "1616672182",
"X-RateLimit-Used": "29",
"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": "A79C:4909:5380D9B:5593FE6:6058A1ED"
"X-GitHub-Request-Id": "D5A4:4AE4:1010476:10B0B89:605C67AC"
}
},
"uuid": "e6db7271-6997-4d05-8074-b0801c3070c3",
"uuid": "a37a5c44-61eb-4460-87e8-3207a15c7d2c",
"persistent": true,
"insertionIndex": 4
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"id": "ff8aef57-0565-4cf8-808f-553679595d1d",
"id": "1ca8cc16-7af0-40c3-832f-197e68817ac1",
"name": "repos_hub4j-test-org_ghworkflowtest_actions_workflows_test-workflowyml",
"request": {
"url": "/repos/hub4j-test-org/GHWorkflowTest/actions/workflows/test-workflow.yml",
Expand All @@ -15,31 +15,31 @@
"bodyFileName": "repos_hub4j-test-org_ghworkflowtest_actions_workflows_test-workflowyml-3.json",
"headers": {
"Server": "GitHub.com",
"Date": "Mon, 22 Mar 2021 13:55:57 GMT",
"Date": "Thu, 25 Mar 2021 10:36:28 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/\"602070ef7b718d94b563e2480e6861839e193e0f9a3b1738f458c302da1d3083\"",
"ETag": "W/\"72a49555d2625ba9f490d619d324726f5192dc2a030dc22033b9cadf7a2ba076\"",
"X-OAuth-Scopes": "repo, user, workflow",
"X-Accepted-OAuth-Scopes": "",
"X-GitHub-Media-Type": "unknown, github.v3",
"X-RateLimit-Limit": "5000",
"X-RateLimit-Remaining": "4727",
"X-RateLimit-Reset": "1616422330",
"X-RateLimit-Used": "273",
"X-RateLimit-Remaining": "4972",
"X-RateLimit-Reset": "1616672182",
"X-RateLimit-Used": "28",
"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": "A79C:4909:5380D66:5593F9E:6058A1ED"
"X-GitHub-Request-Id": "D5A4:4AE4:101045A:10B0B77:605C67AC"
}
},
"uuid": "ff8aef57-0565-4cf8-808f-553679595d1d",
"uuid": "1ca8cc16-7af0-40c3-832f-197e68817ac1",
"persistent": true,
"insertionIndex": 3
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"id": "ddb1ffe0-19de-445f-9215-5b5a49dad5aa",
"id": "c5a67302-c980-47a8-b400-545cf06e8ae7",
"name": "user",
"request": {
"url": "/user",
Expand All @@ -15,32 +15,32 @@
"bodyFileName": "user-1.json",
"headers": {
"Server": "GitHub.com",
"Date": "Mon, 22 Mar 2021 13:55:56 GMT",
"Date": "Thu, 25 Mar 2021 10:36:27 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/\"7913a7993219ab61ca99857c87a65dd9e94b29925239b60463982779c4dd90f1\"",
"Last-Modified": "Mon, 22 Mar 2021 09:43:08 GMT",
"ETag": "W/\"879f35eed38dcc75ca2b3a8999425e0d51678f4c73ffade3c5bcc853b59245b6\"",
"Last-Modified": "Tue, 23 Mar 2021 17:35:45 GMT",
"X-OAuth-Scopes": "repo, user, workflow",
"X-Accepted-OAuth-Scopes": "",
"X-GitHub-Media-Type": "unknown, github.v3",
"X-RateLimit-Limit": "5000",
"X-RateLimit-Remaining": "4732",
"X-RateLimit-Reset": "1616422330",
"X-RateLimit-Used": "268",
"X-RateLimit-Remaining": "4977",
"X-RateLimit-Reset": "1616672182",
"X-RateLimit-Used": "23",
"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": "A79C:4909:5380C69:5593E9B:6058A1EC"
"X-GitHub-Request-Id": "D5A4:4AE4:1010390:10B0A9B:605C67AB"
}
},
"uuid": "ddb1ffe0-19de-445f-9215-5b5a49dad5aa",
"uuid": "c5a67302-c980-47a8-b400-545cf06e8ae7",
"persistent": true,
"insertionIndex": 1
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"path": ".github/workflows/test-workflow.yml",
"state": "active",
"created_at": "2021-03-17T10:33:32.000+01:00",
"updated_at": "2021-03-17T11:29:47.000+01:00",
"updated_at": "2021-03-22T14:55:53.000+01:00",
"url": "https://api.github.com/repos/hub4j-test-org/GHWorkflowTest/actions/workflows/6817859",
"html_url": "https://github.com/hub4j-test-org/GHWorkflowTest/blob/main/.github/workflows/test-workflow.yml",
"badge_url": "https://github.com/hub4j-test-org/GHWorkflowTest/workflows/test-workflow/badge.svg"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"path": ".github/workflows/test-workflow.yml",
"state": "disabled_manually",
"created_at": "2021-03-17T10:33:32.000+01:00",
"updated_at": "2021-03-22T14:55:52.000+01:00",
"updated_at": "2021-03-25T11:36:24.000+01:00",
"url": "https://api.github.com/repos/hub4j-test-org/GHWorkflowTest/actions/workflows/6817859",
"html_url": "https://github.com/hub4j-test-org/GHWorkflowTest/blob/main/.github/workflows/test-workflow.yml",
"badge_url": "https://github.com/hub4j-test-org/GHWorkflowTest/workflows/test-workflow/badge.svg"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"path": ".github/workflows/test-workflow.yml",
"state": "active",
"created_at": "2021-03-17T10:33:32.000+01:00",
"updated_at": "2021-03-22T14:55:53.000+01:00",
"updated_at": "2021-03-25T11:36:24.000+01:00",
"url": "https://api.github.com/repos/hub4j-test-org/GHWorkflowTest/actions/workflows/6817859",
"html_url": "https://github.com/hub4j-test-org/GHWorkflowTest/blob/main/.github/workflows/test-workflow.yml",
"badge_url": "https://github.com/hub4j-test-org/GHWorkflowTest/workflows/test-workflow/badge.svg"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,16 @@
"hireable": null,
"bio": "Happy camper at Red Hat, working on Quarkus and the Hibernate portfolio.",
"twitter_username": "gsmet_",
"public_repos": 100,
"public_repos": 102,
"public_gists": 14,
"followers": 127,
"following": 3,
"created_at": "2011-12-22T11:03:22Z",
"updated_at": "2021-03-22T09:43:08Z",
"updated_at": "2021-03-23T17:35:45Z",
"private_gists": 14,
"total_private_repos": 5,
"owned_private_repos": 2,
"disk_usage": 68251,
"total_private_repos": 4,
"owned_private_repos": 1,
"disk_usage": 68258,
"collaborators": 1,
"two_factor_authentication": true,
"plan": {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"id": "535ca918-972f-4b0b-8ef2-6e5e03369e9c",
"id": "a950e66d-2a80-4b50-97e2-dce79a44902b",
"name": "repos_hub4j-test-org_ghworkflowtest",
"request": {
"url": "/repos/hub4j-test-org/GHWorkflowTest",
Expand All @@ -15,7 +15,7 @@
"bodyFileName": "repos_hub4j-test-org_ghworkflowtest-2.json",
"headers": {
"Server": "GitHub.com",
"Date": "Mon, 22 Mar 2021 13:55:52 GMT",
"Date": "Thu, 25 Mar 2021 10:36:23 GMT",
"Content-Type": "application/json; charset=utf-8",
"Cache-Control": "private, max-age=60, s-maxage=60",
"Vary": [
Expand All @@ -28,19 +28,19 @@
"X-Accepted-OAuth-Scopes": "repo",
"X-GitHub-Media-Type": "unknown, github.v3",
"X-RateLimit-Limit": "5000",
"X-RateLimit-Remaining": "4750",
"X-RateLimit-Reset": "1616422330",
"X-RateLimit-Used": "250",
"X-RateLimit-Remaining": "4995",
"X-RateLimit-Reset": "1616672182",
"X-RateLimit-Used": "5",
"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": "A792:B5ED:367359E:38BF354:6058A1E8"
"X-GitHub-Request-Id": "D598:12325:427F132:4381C9A:605C67A7"
}
},
"uuid": "535ca918-972f-4b0b-8ef2-6e5e03369e9c",
"uuid": "a950e66d-2a80-4b50-97e2-dce79a44902b",
"persistent": true,
"insertionIndex": 2
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"id": "1664d266-9f03-4177-9f92-3727b8d371b2",
"id": "e35b84ba-cdfa-4a74-826a-1ee812336f59",
"name": "repos_hub4j-test-org_ghworkflowtest_actions_workflows_6817859_disable",
"request": {
"url": "/repos/hub4j-test-org/GHWorkflowTest/actions/workflows/6817859/disable",
Expand All @@ -21,25 +21,25 @@
"status": 204,
"headers": {
"Server": "GitHub.com",
"Date": "Mon, 22 Mar 2021 13:55:53 GMT",
"Date": "Thu, 25 Mar 2021 10:36:24 GMT",
"X-OAuth-Scopes": "repo, user, workflow",
"X-Accepted-OAuth-Scopes": "",
"X-GitHub-Media-Type": "unknown, github.v3",
"X-RateLimit-Limit": "5000",
"X-RateLimit-Remaining": "4748",
"X-RateLimit-Reset": "1616422330",
"X-RateLimit-Used": "252",
"X-RateLimit-Remaining": "4993",
"X-RateLimit-Reset": "1616672182",
"X-RateLimit-Used": "7",
"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": "A792:B5ED:36735DE:38BF392:6058A1E8"
"X-GitHub-Request-Id": "D598:12325:427F24B:4381DA8:605C67A7"
}
},
"uuid": "1664d266-9f03-4177-9f92-3727b8d371b2",
"uuid": "e35b84ba-cdfa-4a74-826a-1ee812336f59",
"persistent": true,
"insertionIndex": 4
}
Loading

0 comments on commit d734237

Please sign in to comment.