Skip to content

Commit 73fe4da

Browse files
committed
add tests
1 parent af1d84f commit 73fe4da

File tree

3 files changed

+306
-0
lines changed

3 files changed

+306
-0
lines changed

github/github_test.go

+18
Original file line numberDiff line numberDiff line change
@@ -483,6 +483,24 @@ func TestWebhooks(t *testing.T) {
483483
"X-Github-Event": []string{"security_advisory"},
484484
},
485485
},
486+
{
487+
name: "StarEvent",
488+
event: StarEvent,
489+
typ: StarPayload{},
490+
filename: "../testdata/github/star.json",
491+
headers: http.Header{
492+
"X-Github-Event": []string{"star"},
493+
},
494+
},
495+
{
496+
name: "StarEventDeleted",
497+
event: StarEvent,
498+
typ: StarPayload{},
499+
filename: "../testdata/github/star-deleted.json",
500+
headers: http.Header{
501+
"X-Github-Event": []string{"star"},
502+
},
503+
},
486504
{
487505
name: "StatusEvent",
488506
event: StatusEvent,

testdata/github/star-deleted.json

+144
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,144 @@
1+
{
2+
"action": "deleted",
3+
"starred_at": null,
4+
"repository": {
5+
"id": 906427850,
6+
"node_id": "R_kgDONgb9yg",
7+
"name": "devchain-webhook-test-repo",
8+
"full_name": "bilusteknoloji/devchain-webhook-test-repo",
9+
"private": true,
10+
"owner": {
11+
"login": "bilusteknoloji",
12+
"id": 159630054,
13+
"node_id": "O_kgDOCYPC5g",
14+
"avatar_url": "https://avatars.githubusercontent.com/u/159630054?v=4",
15+
"gravatar_id": "",
16+
"url": "https://api.github.com/users/bilusteknoloji",
17+
"html_url": "https://github.com/bilusteknoloji",
18+
"followers_url": "https://api.github.com/users/bilusteknoloji/followers",
19+
"following_url": "https://api.github.com/users/bilusteknoloji/following{/other_user}",
20+
"gists_url": "https://api.github.com/users/bilusteknoloji/gists{/gist_id}",
21+
"starred_url": "https://api.github.com/users/bilusteknoloji/starred{/owner}{/repo}",
22+
"subscriptions_url": "https://api.github.com/users/bilusteknoloji/subscriptions",
23+
"organizations_url": "https://api.github.com/users/bilusteknoloji/orgs",
24+
"repos_url": "https://api.github.com/users/bilusteknoloji/repos",
25+
"events_url": "https://api.github.com/users/bilusteknoloji/events{/privacy}",
26+
"received_events_url": "https://api.github.com/users/bilusteknoloji/received_events",
27+
"type": "Organization",
28+
"user_view_type": "public",
29+
"site_admin": false
30+
},
31+
"html_url": "https://github.com/bilusteknoloji/devchain-webhook-test-repo",
32+
"description": "This is a dummy repo for testing github webhook payload + events",
33+
"fork": false,
34+
"url": "https://api.github.com/repos/bilusteknoloji/devchain-webhook-test-repo",
35+
"forks_url": "https://api.github.com/repos/bilusteknoloji/devchain-webhook-test-repo/forks",
36+
"keys_url": "https://api.github.com/repos/bilusteknoloji/devchain-webhook-test-repo/keys{/key_id}",
37+
"collaborators_url": "https://api.github.com/repos/bilusteknoloji/devchain-webhook-test-repo/collaborators{/collaborator}",
38+
"teams_url": "https://api.github.com/repos/bilusteknoloji/devchain-webhook-test-repo/teams",
39+
"hooks_url": "https://api.github.com/repos/bilusteknoloji/devchain-webhook-test-repo/hooks",
40+
"issue_events_url": "https://api.github.com/repos/bilusteknoloji/devchain-webhook-test-repo/issues/events{/number}",
41+
"events_url": "https://api.github.com/repos/bilusteknoloji/devchain-webhook-test-repo/events",
42+
"assignees_url": "https://api.github.com/repos/bilusteknoloji/devchain-webhook-test-repo/assignees{/user}",
43+
"branches_url": "https://api.github.com/repos/bilusteknoloji/devchain-webhook-test-repo/branches{/branch}",
44+
"tags_url": "https://api.github.com/repos/bilusteknoloji/devchain-webhook-test-repo/tags",
45+
"blobs_url": "https://api.github.com/repos/bilusteknoloji/devchain-webhook-test-repo/git/blobs{/sha}",
46+
"git_tags_url": "https://api.github.com/repos/bilusteknoloji/devchain-webhook-test-repo/git/tags{/sha}",
47+
"git_refs_url": "https://api.github.com/repos/bilusteknoloji/devchain-webhook-test-repo/git/refs{/sha}",
48+
"trees_url": "https://api.github.com/repos/bilusteknoloji/devchain-webhook-test-repo/git/trees{/sha}",
49+
"statuses_url": "https://api.github.com/repos/bilusteknoloji/devchain-webhook-test-repo/statuses/{sha}",
50+
"languages_url": "https://api.github.com/repos/bilusteknoloji/devchain-webhook-test-repo/languages",
51+
"stargazers_url": "https://api.github.com/repos/bilusteknoloji/devchain-webhook-test-repo/stargazers",
52+
"contributors_url": "https://api.github.com/repos/bilusteknoloji/devchain-webhook-test-repo/contributors",
53+
"subscribers_url": "https://api.github.com/repos/bilusteknoloji/devchain-webhook-test-repo/subscribers",
54+
"subscription_url": "https://api.github.com/repos/bilusteknoloji/devchain-webhook-test-repo/subscription",
55+
"commits_url": "https://api.github.com/repos/bilusteknoloji/devchain-webhook-test-repo/commits{/sha}",
56+
"git_commits_url": "https://api.github.com/repos/bilusteknoloji/devchain-webhook-test-repo/git/commits{/sha}",
57+
"comments_url": "https://api.github.com/repos/bilusteknoloji/devchain-webhook-test-repo/comments{/number}",
58+
"issue_comment_url": "https://api.github.com/repos/bilusteknoloji/devchain-webhook-test-repo/issues/comments{/number}",
59+
"contents_url": "https://api.github.com/repos/bilusteknoloji/devchain-webhook-test-repo/contents/{+path}",
60+
"compare_url": "https://api.github.com/repos/bilusteknoloji/devchain-webhook-test-repo/compare/{base}...{head}",
61+
"merges_url": "https://api.github.com/repos/bilusteknoloji/devchain-webhook-test-repo/merges",
62+
"archive_url": "https://api.github.com/repos/bilusteknoloji/devchain-webhook-test-repo/{archive_format}{/ref}",
63+
"downloads_url": "https://api.github.com/repos/bilusteknoloji/devchain-webhook-test-repo/downloads",
64+
"issues_url": "https://api.github.com/repos/bilusteknoloji/devchain-webhook-test-repo/issues{/number}",
65+
"pulls_url": "https://api.github.com/repos/bilusteknoloji/devchain-webhook-test-repo/pulls{/number}",
66+
"milestones_url": "https://api.github.com/repos/bilusteknoloji/devchain-webhook-test-repo/milestones{/number}",
67+
"notifications_url": "https://api.github.com/repos/bilusteknoloji/devchain-webhook-test-repo/notifications{?since,all,participating}",
68+
"labels_url": "https://api.github.com/repos/bilusteknoloji/devchain-webhook-test-repo/labels{/name}",
69+
"releases_url": "https://api.github.com/repos/bilusteknoloji/devchain-webhook-test-repo/releases{/id}",
70+
"deployments_url": "https://api.github.com/repos/bilusteknoloji/devchain-webhook-test-repo/deployments",
71+
"created_at": "2024-12-20T22:20:56Z",
72+
"updated_at": "2025-01-10T17:24:56Z",
73+
"pushed_at": "2025-01-09T10:09:35Z",
74+
"git_url": "git://github.com/bilusteknoloji/devchain-webhook-test-repo.git",
75+
"ssh_url": "[email protected]:bilusteknoloji/devchain-webhook-test-repo.git",
76+
"clone_url": "https://github.com/bilusteknoloji/devchain-webhook-test-repo.git",
77+
"svn_url": "https://github.com/bilusteknoloji/devchain-webhook-test-repo",
78+
"homepage": null,
79+
"size": 10,
80+
"stargazers_count": 1,
81+
"watchers_count": 1,
82+
"language": null,
83+
"has_issues": true,
84+
"has_projects": false,
85+
"has_downloads": true,
86+
"has_wiki": false,
87+
"has_pages": false,
88+
"has_discussions": false,
89+
"forks_count": 0,
90+
"mirror_url": null,
91+
"archived": false,
92+
"disabled": false,
93+
"open_issues_count": 8,
94+
"license": null,
95+
"allow_forking": false,
96+
"is_template": false,
97+
"web_commit_signoff_required": false,
98+
"topics": [
99+
100+
],
101+
"visibility": "private",
102+
"forks": 0,
103+
"open_issues": 8,
104+
"watchers": 1,
105+
"default_branch": "main",
106+
"custom_properties": {
107+
}
108+
},
109+
"organization": {
110+
"login": "bilusteknoloji",
111+
"id": 159630054,
112+
"node_id": "O_kgDOCYPC5g",
113+
"url": "https://api.github.com/orgs/bilusteknoloji",
114+
"repos_url": "https://api.github.com/orgs/bilusteknoloji/repos",
115+
"events_url": "https://api.github.com/orgs/bilusteknoloji/events",
116+
"hooks_url": "https://api.github.com/orgs/bilusteknoloji/hooks",
117+
"issues_url": "https://api.github.com/orgs/bilusteknoloji/issues",
118+
"members_url": "https://api.github.com/orgs/bilusteknoloji/members{/member}",
119+
"public_members_url": "https://api.github.com/orgs/bilusteknoloji/public_members{/member}",
120+
"avatar_url": "https://avatars.githubusercontent.com/u/159630054?v=4",
121+
"description": "Software Development and Consultancy"
122+
},
123+
"sender": {
124+
"login": "vigo",
125+
"id": 82952,
126+
"node_id": "MDQ6VXNlcjgyOTUy",
127+
"avatar_url": "https://avatars.githubusercontent.com/u/82952?v=4",
128+
"gravatar_id": "",
129+
"url": "https://api.github.com/users/vigo",
130+
"html_url": "https://github.com/vigo",
131+
"followers_url": "https://api.github.com/users/vigo/followers",
132+
"following_url": "https://api.github.com/users/vigo/following{/other_user}",
133+
"gists_url": "https://api.github.com/users/vigo/gists{/gist_id}",
134+
"starred_url": "https://api.github.com/users/vigo/starred{/owner}{/repo}",
135+
"subscriptions_url": "https://api.github.com/users/vigo/subscriptions",
136+
"organizations_url": "https://api.github.com/users/vigo/orgs",
137+
"repos_url": "https://api.github.com/users/vigo/repos",
138+
"events_url": "https://api.github.com/users/vigo/events{/privacy}",
139+
"received_events_url": "https://api.github.com/users/vigo/received_events",
140+
"type": "User",
141+
"user_view_type": "public",
142+
"site_admin": false
143+
}
144+
}

testdata/github/star.json

+144
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,144 @@
1+
{
2+
"action": "created",
3+
"starred_at": "2025-01-10T17:01:42Z",
4+
"repository": {
5+
"id": 906427850,
6+
"node_id": "R_kgDONgb9yg",
7+
"name": "devchain-webhook-test-repo",
8+
"full_name": "bilusteknoloji/devchain-webhook-test-repo",
9+
"private": true,
10+
"owner": {
11+
"login": "bilusteknoloji",
12+
"id": 159630054,
13+
"node_id": "O_kgDOCYPC5g",
14+
"avatar_url": "https://avatars.githubusercontent.com/u/159630054?v=4",
15+
"gravatar_id": "",
16+
"url": "https://api.github.com/users/bilusteknoloji",
17+
"html_url": "https://github.com/bilusteknoloji",
18+
"followers_url": "https://api.github.com/users/bilusteknoloji/followers",
19+
"following_url": "https://api.github.com/users/bilusteknoloji/following{/other_user}",
20+
"gists_url": "https://api.github.com/users/bilusteknoloji/gists{/gist_id}",
21+
"starred_url": "https://api.github.com/users/bilusteknoloji/starred{/owner}{/repo}",
22+
"subscriptions_url": "https://api.github.com/users/bilusteknoloji/subscriptions",
23+
"organizations_url": "https://api.github.com/users/bilusteknoloji/orgs",
24+
"repos_url": "https://api.github.com/users/bilusteknoloji/repos",
25+
"events_url": "https://api.github.com/users/bilusteknoloji/events{/privacy}",
26+
"received_events_url": "https://api.github.com/users/bilusteknoloji/received_events",
27+
"type": "Organization",
28+
"user_view_type": "public",
29+
"site_admin": false
30+
},
31+
"html_url": "https://github.com/bilusteknoloji/devchain-webhook-test-repo",
32+
"description": "This is a dummy repo for testing github webhook payload + events",
33+
"fork": false,
34+
"url": "https://api.github.com/repos/bilusteknoloji/devchain-webhook-test-repo",
35+
"forks_url": "https://api.github.com/repos/bilusteknoloji/devchain-webhook-test-repo/forks",
36+
"keys_url": "https://api.github.com/repos/bilusteknoloji/devchain-webhook-test-repo/keys{/key_id}",
37+
"collaborators_url": "https://api.github.com/repos/bilusteknoloji/devchain-webhook-test-repo/collaborators{/collaborator}",
38+
"teams_url": "https://api.github.com/repos/bilusteknoloji/devchain-webhook-test-repo/teams",
39+
"hooks_url": "https://api.github.com/repos/bilusteknoloji/devchain-webhook-test-repo/hooks",
40+
"issue_events_url": "https://api.github.com/repos/bilusteknoloji/devchain-webhook-test-repo/issues/events{/number}",
41+
"events_url": "https://api.github.com/repos/bilusteknoloji/devchain-webhook-test-repo/events",
42+
"assignees_url": "https://api.github.com/repos/bilusteknoloji/devchain-webhook-test-repo/assignees{/user}",
43+
"branches_url": "https://api.github.com/repos/bilusteknoloji/devchain-webhook-test-repo/branches{/branch}",
44+
"tags_url": "https://api.github.com/repos/bilusteknoloji/devchain-webhook-test-repo/tags",
45+
"blobs_url": "https://api.github.com/repos/bilusteknoloji/devchain-webhook-test-repo/git/blobs{/sha}",
46+
"git_tags_url": "https://api.github.com/repos/bilusteknoloji/devchain-webhook-test-repo/git/tags{/sha}",
47+
"git_refs_url": "https://api.github.com/repos/bilusteknoloji/devchain-webhook-test-repo/git/refs{/sha}",
48+
"trees_url": "https://api.github.com/repos/bilusteknoloji/devchain-webhook-test-repo/git/trees{/sha}",
49+
"statuses_url": "https://api.github.com/repos/bilusteknoloji/devchain-webhook-test-repo/statuses/{sha}",
50+
"languages_url": "https://api.github.com/repos/bilusteknoloji/devchain-webhook-test-repo/languages",
51+
"stargazers_url": "https://api.github.com/repos/bilusteknoloji/devchain-webhook-test-repo/stargazers",
52+
"contributors_url": "https://api.github.com/repos/bilusteknoloji/devchain-webhook-test-repo/contributors",
53+
"subscribers_url": "https://api.github.com/repos/bilusteknoloji/devchain-webhook-test-repo/subscribers",
54+
"subscription_url": "https://api.github.com/repos/bilusteknoloji/devchain-webhook-test-repo/subscription",
55+
"commits_url": "https://api.github.com/repos/bilusteknoloji/devchain-webhook-test-repo/commits{/sha}",
56+
"git_commits_url": "https://api.github.com/repos/bilusteknoloji/devchain-webhook-test-repo/git/commits{/sha}",
57+
"comments_url": "https://api.github.com/repos/bilusteknoloji/devchain-webhook-test-repo/comments{/number}",
58+
"issue_comment_url": "https://api.github.com/repos/bilusteknoloji/devchain-webhook-test-repo/issues/comments{/number}",
59+
"contents_url": "https://api.github.com/repos/bilusteknoloji/devchain-webhook-test-repo/contents/{+path}",
60+
"compare_url": "https://api.github.com/repos/bilusteknoloji/devchain-webhook-test-repo/compare/{base}...{head}",
61+
"merges_url": "https://api.github.com/repos/bilusteknoloji/devchain-webhook-test-repo/merges",
62+
"archive_url": "https://api.github.com/repos/bilusteknoloji/devchain-webhook-test-repo/{archive_format}{/ref}",
63+
"downloads_url": "https://api.github.com/repos/bilusteknoloji/devchain-webhook-test-repo/downloads",
64+
"issues_url": "https://api.github.com/repos/bilusteknoloji/devchain-webhook-test-repo/issues{/number}",
65+
"pulls_url": "https://api.github.com/repos/bilusteknoloji/devchain-webhook-test-repo/pulls{/number}",
66+
"milestones_url": "https://api.github.com/repos/bilusteknoloji/devchain-webhook-test-repo/milestones{/number}",
67+
"notifications_url": "https://api.github.com/repos/bilusteknoloji/devchain-webhook-test-repo/notifications{?since,all,participating}",
68+
"labels_url": "https://api.github.com/repos/bilusteknoloji/devchain-webhook-test-repo/labels{/name}",
69+
"releases_url": "https://api.github.com/repos/bilusteknoloji/devchain-webhook-test-repo/releases{/id}",
70+
"deployments_url": "https://api.github.com/repos/bilusteknoloji/devchain-webhook-test-repo/deployments",
71+
"created_at": "2024-12-20T22:20:56Z",
72+
"updated_at": "2025-01-10T17:01:43Z",
73+
"pushed_at": "2025-01-09T10:09:35Z",
74+
"git_url": "git://github.com/bilusteknoloji/devchain-webhook-test-repo.git",
75+
"ssh_url": "[email protected]:bilusteknoloji/devchain-webhook-test-repo.git",
76+
"clone_url": "https://github.com/bilusteknoloji/devchain-webhook-test-repo.git",
77+
"svn_url": "https://github.com/bilusteknoloji/devchain-webhook-test-repo",
78+
"homepage": null,
79+
"size": 10,
80+
"stargazers_count": 2,
81+
"watchers_count": 2,
82+
"language": null,
83+
"has_issues": true,
84+
"has_projects": false,
85+
"has_downloads": true,
86+
"has_wiki": false,
87+
"has_pages": false,
88+
"has_discussions": false,
89+
"forks_count": 0,
90+
"mirror_url": null,
91+
"archived": false,
92+
"disabled": false,
93+
"open_issues_count": 8,
94+
"license": null,
95+
"allow_forking": false,
96+
"is_template": false,
97+
"web_commit_signoff_required": false,
98+
"topics": [
99+
100+
],
101+
"visibility": "private",
102+
"forks": 0,
103+
"open_issues": 8,
104+
"watchers": 2,
105+
"default_branch": "main",
106+
"custom_properties": {
107+
}
108+
},
109+
"organization": {
110+
"login": "bilusteknoloji",
111+
"id": 159630054,
112+
"node_id": "O_kgDOCYPC5g",
113+
"url": "https://api.github.com/orgs/bilusteknoloji",
114+
"repos_url": "https://api.github.com/orgs/bilusteknoloji/repos",
115+
"events_url": "https://api.github.com/orgs/bilusteknoloji/events",
116+
"hooks_url": "https://api.github.com/orgs/bilusteknoloji/hooks",
117+
"issues_url": "https://api.github.com/orgs/bilusteknoloji/issues",
118+
"members_url": "https://api.github.com/orgs/bilusteknoloji/members{/member}",
119+
"public_members_url": "https://api.github.com/orgs/bilusteknoloji/public_members{/member}",
120+
"avatar_url": "https://avatars.githubusercontent.com/u/159630054?v=4",
121+
"description": "Software Development and Consultancy"
122+
},
123+
"sender": {
124+
"login": "vigo",
125+
"id": 82952,
126+
"node_id": "MDQ6VXNlcjgyOTUy",
127+
"avatar_url": "https://avatars.githubusercontent.com/u/82952?v=4",
128+
"gravatar_id": "",
129+
"url": "https://api.github.com/users/vigo",
130+
"html_url": "https://github.com/vigo",
131+
"followers_url": "https://api.github.com/users/vigo/followers",
132+
"following_url": "https://api.github.com/users/vigo/following{/other_user}",
133+
"gists_url": "https://api.github.com/users/vigo/gists{/gist_id}",
134+
"starred_url": "https://api.github.com/users/vigo/starred{/owner}{/repo}",
135+
"subscriptions_url": "https://api.github.com/users/vigo/subscriptions",
136+
"organizations_url": "https://api.github.com/users/vigo/orgs",
137+
"repos_url": "https://api.github.com/users/vigo/repos",
138+
"events_url": "https://api.github.com/users/vigo/events{/privacy}",
139+
"received_events_url": "https://api.github.com/users/vigo/received_events",
140+
"type": "User",
141+
"user_view_type": "public",
142+
"site_admin": false
143+
}
144+
}

0 commit comments

Comments
 (0)