Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit c25068e

Browse filesBrowse files
committed
Add test for pull request project card
1 parent 0c71293 commit c25068e
Copy full SHA for c25068e

File tree

Expand file treeCollapse file tree

31 files changed

+1817
-1
lines changed
Filter options
Expand file treeCollapse file tree

31 files changed

+1817
-1
lines changed

‎src/main/java/org/kohsuke/github/GHProjectColumn.java

Copy file name to clipboardExpand all lines: src/main/java/org/kohsuke/github/GHProjectColumn.java
+2-1Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,10 +186,11 @@ public GHProjectCard createCard(String note) throws IOException {
186186
* the io exception
187187
*/
188188
public GHProjectCard createCard(GHIssue issue) throws IOException {
189+
String contentType = issue instanceof GHPullRequest ? "PullRequest" : "Issue";
189190
return root().createRequest()
190191
.method("POST")
191192
.withPreview(INERTIA)
192-
.with("content_type", issue instanceof GHPullRequest ? "PullRequest" : "Issue")
193+
.with("content_type", contentType)
193194
.with("content_id", issue.getId())
194195
.withUrlPath(String.format("/projects/columns/%d/cards", getId()))
195196
.fetch(GHProjectCard.class)

‎src/test/java/org/kohsuke/github/GHProjectCardTest.java

Copy file name to clipboardExpand all lines: src/test/java/org/kohsuke/github/GHProjectCardTest.java
+26Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,32 @@ public void testCreateCardFromIssue() throws IOException {
6262
}
6363
}
6464

65+
@Test
66+
public void testCreateCardFromPR() throws IOException {
67+
GHRepository repo = org.createRepository("repo-for-project-card").autoInit(true).create();
68+
69+
try {
70+
String mainHead = repo.getRef("heads/main").getObject().getSha();
71+
String branchName1 = "refs/heads/branch1";
72+
repo.createRef(branchName1, mainHead);
73+
repo.createContent()
74+
.content(branchName1)
75+
.message(branchName1)
76+
.path(branchName1)
77+
.branch(branchName1)
78+
.commit();
79+
GHPullRequest pr = repo.createPullRequest("new-PR", branchName1, "refs/heads/main", "Body Text");
80+
GHProjectCard card = column.createCard(pr);
81+
// For some reason, PRs are still treated as issues in project card urls
82+
assertThat(card.getContentUrl().toString(), equalTo(pr.getUrl().toString().replace("/pulls/", "/issues/")));
83+
assertThat(card.getContent().getUrl().toString(),
84+
equalTo(pr.getUrl().toString().replace("/pulls/", "/issues/")));
85+
assertThat(card.getContent().getRepository().getUrl(), equalTo(repo.getUrl()));
86+
} finally {
87+
repo.delete();
88+
}
89+
}
90+
6591
@Test
6692
public void testDeleteCard() throws IOException {
6793
card.delete();
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
{
2+
"login": "hub4j-test-org",
3+
"id": 7544739,
4+
"node_id": "MDEyOk9yZ2FuaXphdGlvbjc1NDQ3Mzk=",
5+
"url": "https://api.github.com/orgs/hub4j-test-org",
6+
"repos_url": "https://api.github.com/orgs/hub4j-test-org/repos",
7+
"events_url": "https://api.github.com/orgs/hub4j-test-org/events",
8+
"hooks_url": "https://api.github.com/orgs/hub4j-test-org/hooks",
9+
"issues_url": "https://api.github.com/orgs/hub4j-test-org/issues",
10+
"members_url": "https://api.github.com/orgs/hub4j-test-org/members{/member}",
11+
"public_members_url": "https://api.github.com/orgs/hub4j-test-org/public_members{/member}",
12+
"avatar_url": "https://avatars.githubusercontent.com/u/7544739?v=4",
13+
"description": "Hub4j Test Org Description (this could be null or blank too)",
14+
"name": "Hub4j Test Org Name (this could be null or blank too)",
15+
"company": null,
16+
"blog": "https://hub4j.url.io/could/be/null",
17+
"location": "Hub4j Test Org Location (this could be null or blank too)",
18+
"email": "hub4jtestorgemail@could.be.null.com",
19+
"twitter_username": null,
20+
"is_verified": false,
21+
"has_organization_projects": true,
22+
"has_repository_projects": true,
23+
"public_repos": 20,
24+
"public_gists": 0,
25+
"followers": 0,
26+
"following": 0,
27+
"html_url": "https://github.com/hub4j-test-org",
28+
"created_at": "2014-05-10T19:39:11Z",
29+
"updated_at": "2020-06-04T05:56:10Z",
30+
"type": "Organization",
31+
"total_private_repos": 2,
32+
"owned_private_repos": 2,
33+
"private_gists": 0,
34+
"disk_usage": 11979,
35+
"collaborators": 0,
36+
"billing_email": "kk@kohsuke.org",
37+
"default_repository_permission": "none",
38+
"members_can_create_repositories": false,
39+
"two_factor_requirement_enabled": false,
40+
"members_allowed_repository_creation_type": "none",
41+
"members_can_create_public_repositories": false,
42+
"members_can_create_private_repositories": false,
43+
"members_can_create_internal_repositories": false,
44+
"members_can_create_pages": true,
45+
"members_can_create_public_pages": true,
46+
"members_can_create_private_pages": true,
47+
"plan": {
48+
"name": "free",
49+
"space": 976562499,
50+
"private_repos": 10000,
51+
"filled_seats": 29,
52+
"seats": 3
53+
}
54+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
{
2+
"owner_url": "https://api.github.com/orgs/hub4j-test-org",
3+
"url": "https://api.github.com/projects/13577338",
4+
"html_url": "https://github.com/orgs/hub4j-test-org/projects/42",
5+
"columns_url": "https://api.github.com/projects/13577338/columns",
6+
"id": 13577338,
7+
"node_id": "PRO_kwDOAHMfo84Azyx6",
8+
"name": "test-project",
9+
"body": "This is a test project",
10+
"number": 42,
11+
"state": "open",
12+
"creator": {
13+
"login": "bitwiseman",
14+
"id": 1958953,
15+
"node_id": "MDQ6VXNlcjE5NTg5NTM=",
16+
"avatar_url": "https://avatars.githubusercontent.com/u/1958953?v=4",
17+
"gravatar_id": "",
18+
"url": "https://api.github.com/users/bitwiseman",
19+
"html_url": "https://github.com/bitwiseman",
20+
"followers_url": "https://api.github.com/users/bitwiseman/followers",
21+
"following_url": "https://api.github.com/users/bitwiseman/following{/other_user}",
22+
"gists_url": "https://api.github.com/users/bitwiseman/gists{/gist_id}",
23+
"starred_url": "https://api.github.com/users/bitwiseman/starred{/owner}{/repo}",
24+
"subscriptions_url": "https://api.github.com/users/bitwiseman/subscriptions",
25+
"organizations_url": "https://api.github.com/users/bitwiseman/orgs",
26+
"repos_url": "https://api.github.com/users/bitwiseman/repos",
27+
"events_url": "https://api.github.com/users/bitwiseman/events{/privacy}",
28+
"received_events_url": "https://api.github.com/users/bitwiseman/received_events",
29+
"type": "User",
30+
"site_admin": false
31+
},
32+
"created_at": "2021-10-21T06:17:47Z",
33+
"updated_at": "2021-10-21T06:17:47Z",
34+
"organization_permission": "write",
35+
"private": true
36+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
{
2+
"id": 419604238,
3+
"node_id": "R_kgDOGQKnDg",
4+
"name": "repo-for-project-card",
5+
"full_name": "hub4j-test-org/repo-for-project-card",
6+
"private": false,
7+
"owner": {
8+
"login": "hub4j-test-org",
9+
"id": 7544739,
10+
"node_id": "MDEyOk9yZ2FuaXphdGlvbjc1NDQ3Mzk=",
11+
"avatar_url": "https://avatars.githubusercontent.com/u/7544739?v=4",
12+
"gravatar_id": "",
13+
"url": "https://api.github.com/users/hub4j-test-org",
14+
"html_url": "https://github.com/hub4j-test-org",
15+
"followers_url": "https://api.github.com/users/hub4j-test-org/followers",
16+
"following_url": "https://api.github.com/users/hub4j-test-org/following{/other_user}",
17+
"gists_url": "https://api.github.com/users/hub4j-test-org/gists{/gist_id}",
18+
"starred_url": "https://api.github.com/users/hub4j-test-org/starred{/owner}{/repo}",
19+
"subscriptions_url": "https://api.github.com/users/hub4j-test-org/subscriptions",
20+
"organizations_url": "https://api.github.com/users/hub4j-test-org/orgs",
21+
"repos_url": "https://api.github.com/users/hub4j-test-org/repos",
22+
"events_url": "https://api.github.com/users/hub4j-test-org/events{/privacy}",
23+
"received_events_url": "https://api.github.com/users/hub4j-test-org/received_events",
24+
"type": "Organization",
25+
"site_admin": false
26+
},
27+
"html_url": "https://github.com/hub4j-test-org/repo-for-project-card",
28+
"description": null,
29+
"fork": false,
30+
"url": "https://api.github.com/repos/hub4j-test-org/repo-for-project-card",
31+
"forks_url": "https://api.github.com/repos/hub4j-test-org/repo-for-project-card/forks",
32+
"keys_url": "https://api.github.com/repos/hub4j-test-org/repo-for-project-card/keys{/key_id}",
33+
"collaborators_url": "https://api.github.com/repos/hub4j-test-org/repo-for-project-card/collaborators{/collaborator}",
34+
"teams_url": "https://api.github.com/repos/hub4j-test-org/repo-for-project-card/teams",
35+
"hooks_url": "https://api.github.com/repos/hub4j-test-org/repo-for-project-card/hooks",
36+
"issue_events_url": "https://api.github.com/repos/hub4j-test-org/repo-for-project-card/issues/events{/number}",
37+
"events_url": "https://api.github.com/repos/hub4j-test-org/repo-for-project-card/events",
38+
"assignees_url": "https://api.github.com/repos/hub4j-test-org/repo-for-project-card/assignees{/user}",
39+
"branches_url": "https://api.github.com/repos/hub4j-test-org/repo-for-project-card/branches{/branch}",
40+
"tags_url": "https://api.github.com/repos/hub4j-test-org/repo-for-project-card/tags",
41+
"blobs_url": "https://api.github.com/repos/hub4j-test-org/repo-for-project-card/git/blobs{/sha}",
42+
"git_tags_url": "https://api.github.com/repos/hub4j-test-org/repo-for-project-card/git/tags{/sha}",
43+
"git_refs_url": "https://api.github.com/repos/hub4j-test-org/repo-for-project-card/git/refs{/sha}",
44+
"trees_url": "https://api.github.com/repos/hub4j-test-org/repo-for-project-card/git/trees{/sha}",
45+
"statuses_url": "https://api.github.com/repos/hub4j-test-org/repo-for-project-card/statuses/{sha}",
46+
"languages_url": "https://api.github.com/repos/hub4j-test-org/repo-for-project-card/languages",
47+
"stargazers_url": "https://api.github.com/repos/hub4j-test-org/repo-for-project-card/stargazers",
48+
"contributors_url": "https://api.github.com/repos/hub4j-test-org/repo-for-project-card/contributors",
49+
"subscribers_url": "https://api.github.com/repos/hub4j-test-org/repo-for-project-card/subscribers",
50+
"subscription_url": "https://api.github.com/repos/hub4j-test-org/repo-for-project-card/subscription",
51+
"commits_url": "https://api.github.com/repos/hub4j-test-org/repo-for-project-card/commits{/sha}",
52+
"git_commits_url": "https://api.github.com/repos/hub4j-test-org/repo-for-project-card/git/commits{/sha}",
53+
"comments_url": "https://api.github.com/repos/hub4j-test-org/repo-for-project-card/comments{/number}",
54+
"issue_comment_url": "https://api.github.com/repos/hub4j-test-org/repo-for-project-card/issues/comments{/number}",
55+
"contents_url": "https://api.github.com/repos/hub4j-test-org/repo-for-project-card/contents/{+path}",
56+
"compare_url": "https://api.github.com/repos/hub4j-test-org/repo-for-project-card/compare/{base}...{head}",
57+
"merges_url": "https://api.github.com/repos/hub4j-test-org/repo-for-project-card/merges",
58+
"archive_url": "https://api.github.com/repos/hub4j-test-org/repo-for-project-card/{archive_format}{/ref}",
59+
"downloads_url": "https://api.github.com/repos/hub4j-test-org/repo-for-project-card/downloads",
60+
"issues_url": "https://api.github.com/repos/hub4j-test-org/repo-for-project-card/issues{/number}",
61+
"pulls_url": "https://api.github.com/repos/hub4j-test-org/repo-for-project-card/pulls{/number}",
62+
"milestones_url": "https://api.github.com/repos/hub4j-test-org/repo-for-project-card/milestones{/number}",
63+
"notifications_url": "https://api.github.com/repos/hub4j-test-org/repo-for-project-card/notifications{?since,all,participating}",
64+
"labels_url": "https://api.github.com/repos/hub4j-test-org/repo-for-project-card/labels{/name}",
65+
"releases_url": "https://api.github.com/repos/hub4j-test-org/repo-for-project-card/releases{/id}",
66+
"deployments_url": "https://api.github.com/repos/hub4j-test-org/repo-for-project-card/deployments",
67+
"created_at": "2021-10-21T06:17:48Z",
68+
"updated_at": "2021-10-21T06:17:48Z",
69+
"pushed_at": "2021-10-21T06:17:49Z",
70+
"git_url": "git://github.com/hub4j-test-org/repo-for-project-card.git",
71+
"ssh_url": "git@github.com:hub4j-test-org/repo-for-project-card.git",
72+
"clone_url": "https://github.com/hub4j-test-org/repo-for-project-card.git",
73+
"svn_url": "https://github.com/hub4j-test-org/repo-for-project-card",
74+
"homepage": null,
75+
"size": 0,
76+
"stargazers_count": 0,
77+
"watchers_count": 0,
78+
"language": null,
79+
"has_issues": true,
80+
"has_projects": true,
81+
"has_downloads": true,
82+
"has_wiki": true,
83+
"has_pages": false,
84+
"forks_count": 0,
85+
"mirror_url": null,
86+
"archived": false,
87+
"disabled": false,
88+
"open_issues_count": 0,
89+
"license": null,
90+
"allow_forking": true,
91+
"is_template": false,
92+
"topics": [],
93+
"visibility": "public",
94+
"forks": 0,
95+
"open_issues": 0,
96+
"watchers": 0,
97+
"default_branch": "main",
98+
"permissions": {
99+
"admin": true,
100+
"maintain": true,
101+
"push": true,
102+
"triage": true,
103+
"pull": true
104+
},
105+
"allow_squash_merge": true,
106+
"allow_merge_commit": true,
107+
"allow_rebase_merge": true,
108+
"allow_auto_merge": false,
109+
"delete_branch_on_merge": false,
110+
"organization": {
111+
"login": "hub4j-test-org",
112+
"id": 7544739,
113+
"node_id": "MDEyOk9yZ2FuaXphdGlvbjc1NDQ3Mzk=",
114+
"avatar_url": "https://avatars.githubusercontent.com/u/7544739?v=4",
115+
"gravatar_id": "",
116+
"url": "https://api.github.com/users/hub4j-test-org",
117+
"html_url": "https://github.com/hub4j-test-org",
118+
"followers_url": "https://api.github.com/users/hub4j-test-org/followers",
119+
"following_url": "https://api.github.com/users/hub4j-test-org/following{/other_user}",
120+
"gists_url": "https://api.github.com/users/hub4j-test-org/gists{/gist_id}",
121+
"starred_url": "https://api.github.com/users/hub4j-test-org/starred{/owner}{/repo}",
122+
"subscriptions_url": "https://api.github.com/users/hub4j-test-org/subscriptions",
123+
"organizations_url": "https://api.github.com/users/hub4j-test-org/orgs",
124+
"repos_url": "https://api.github.com/users/hub4j-test-org/repos",
125+
"events_url": "https://api.github.com/users/hub4j-test-org/events{/privacy}",
126+
"received_events_url": "https://api.github.com/users/hub4j-test-org/received_events",
127+
"type": "Organization",
128+
"site_admin": false
129+
},
130+
"network_count": 0,
131+
"subscribers_count": 7
132+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"url": "https://api.github.com/projects/columns/16515524",
3+
"project_url": "https://api.github.com/projects/13577338",
4+
"cards_url": "https://api.github.com/projects/columns/16515524/cards",
5+
"id": 16515524,
6+
"node_id": "PC_lAPOAHMfo84Azyx6zgD8AcQ",
7+
"name": "column-one",
8+
"created_at": "2021-10-21T06:17:47Z",
9+
"updated_at": "2021-10-21T06:17:47Z"
10+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
{
2+
"url": "https://api.github.com/projects/columns/cards/71268716",
3+
"project_url": "https://api.github.com/projects/13577338",
4+
"id": 71268716,
5+
"node_id": "PRC_lADOAHMfo84Azyx6zgQ_eWw",
6+
"note": null,
7+
"archived": false,
8+
"creator": {
9+
"login": "bitwiseman",
10+
"id": 1958953,
11+
"node_id": "MDQ6VXNlcjE5NTg5NTM=",
12+
"avatar_url": "https://avatars.githubusercontent.com/u/1958953?v=4",
13+
"gravatar_id": "",
14+
"url": "https://api.github.com/users/bitwiseman",
15+
"html_url": "https://github.com/bitwiseman",
16+
"followers_url": "https://api.github.com/users/bitwiseman/followers",
17+
"following_url": "https://api.github.com/users/bitwiseman/following{/other_user}",
18+
"gists_url": "https://api.github.com/users/bitwiseman/gists{/gist_id}",
19+
"starred_url": "https://api.github.com/users/bitwiseman/starred{/owner}{/repo}",
20+
"subscriptions_url": "https://api.github.com/users/bitwiseman/subscriptions",
21+
"organizations_url": "https://api.github.com/users/bitwiseman/orgs",
22+
"repos_url": "https://api.github.com/users/bitwiseman/repos",
23+
"events_url": "https://api.github.com/users/bitwiseman/events{/privacy}",
24+
"received_events_url": "https://api.github.com/users/bitwiseman/received_events",
25+
"type": "User",
26+
"site_admin": false
27+
},
28+
"created_at": "2021-10-21T06:17:51Z",
29+
"updated_at": "2021-10-21T06:17:51Z",
30+
"column_url": "https://api.github.com/projects/columns/16515524",
31+
"content_url": "https://api.github.com/repos/hub4j-test-org/repo-for-project-card/issues/1"
32+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
{
2+
"url": "https://api.github.com/projects/columns/cards/71268713",
3+
"project_url": "https://api.github.com/projects/13577338",
4+
"id": 71268713,
5+
"node_id": "PRC_lADOAHMfo84Azyx6zgQ_eWk",
6+
"note": "This is a card",
7+
"archived": false,
8+
"creator": {
9+
"login": "bitwiseman",
10+
"id": 1958953,
11+
"node_id": "MDQ6VXNlcjE5NTg5NTM=",
12+
"avatar_url": "https://avatars.githubusercontent.com/u/1958953?v=4",
13+
"gravatar_id": "",
14+
"url": "https://api.github.com/users/bitwiseman",
15+
"html_url": "https://github.com/bitwiseman",
16+
"followers_url": "https://api.github.com/users/bitwiseman/followers",
17+
"following_url": "https://api.github.com/users/bitwiseman/following{/other_user}",
18+
"gists_url": "https://api.github.com/users/bitwiseman/gists{/gist_id}",
19+
"starred_url": "https://api.github.com/users/bitwiseman/starred{/owner}{/repo}",
20+
"subscriptions_url": "https://api.github.com/users/bitwiseman/subscriptions",
21+
"organizations_url": "https://api.github.com/users/bitwiseman/orgs",
22+
"repos_url": "https://api.github.com/users/bitwiseman/repos",
23+
"events_url": "https://api.github.com/users/bitwiseman/events{/privacy}",
24+
"received_events_url": "https://api.github.com/users/bitwiseman/received_events",
25+
"type": "User",
26+
"site_admin": false
27+
},
28+
"created_at": "2021-10-21T06:17:47Z",
29+
"updated_at": "2021-10-21T06:17:47Z",
30+
"column_url": "https://api.github.com/projects/columns/16515524"
31+
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.