From 62af9fc17bc679744d06917a474a8dffe6459a42 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rudstr=C3=B8m?= Date: Wed, 9 Oct 2019 20:04:06 +0200 Subject: [PATCH] removed some uncesserary changes to testdata --- github/payload.go | 43 +++++----- scrape/github.go | 2 +- testdata/github/check-run.json | 26 +++--- testdata/github/check-suite.json | 6 +- testdata/github/meta.json | 2 +- .../github/pull-request-review-comment.json | 17 ++-- testdata/github/pull-request-review.json | 18 +---- testdata/github/pull-request.json | 81 ++----------------- 8 files changed, 64 insertions(+), 131 deletions(-) diff --git a/github/payload.go b/github/payload.go index 230bb5b..6f82ada 100644 --- a/github/payload.go +++ b/github/payload.go @@ -31,24 +31,24 @@ type CheckPullRequest struct { type CheckRunPayload struct { Action string `json:"action"` CheckRun struct { - ID int64 `json:"id"` - NodeID string `json:"node_id"` - Name string `json:"name"` - HeadSHA string `json:"head_sha"` - Status string `json:"status"` - Conclusion string `json:"conclusion"` - URL string `json:"url"` - HtmlURL string `json:"html_url"` - StarterAt time.Time `json:"started_at"` - CompletedAt time.Time `json:"completed_at"` - DetailsURL string `json:"details_url"` - ExternalID string `json:"external_id"` + ID int64 `json:"id"` + NodeID string `json:"node_id"` + Name string `json:"name"` + HeadSHA string `json:"head_sha"` + Status string `json:"status"` + Conclusion *string `json:"conclusion"` + URL string `json:"url"` + HtmlURL string `json:"html_url"` + StarterAt time.Time `json:"started_at"` + CompletedAt *time.Time `json:"completed_at"` + DetailsURL string `json:"details_url"` + ExternalID string `json:"external_id"` Output struct { - Title string `json:"title"` - Summary string `json:"summary"` - Text string `json:"text"` - AnnotationsCount int64 `json:"annotations_count"` - AnnotationsURL string `json:"annotations_url"` + Title *string `json:"title"` + Summary *string `json:"summary"` + Text *string `json:"text"` + AnnotationsCount int64 `json:"annotations_count"` + AnnotationsURL string `json:"annotations_url"` } `json:"output"` CheckSuite struct { ID int64 `json:"id"` @@ -56,7 +56,7 @@ type CheckRunPayload struct { HeadBranch string `json:"head_branch"` HeadSHA string `json:"head_sha"` Status string `json:"status"` - Conclusion string `json:"conclusion"` + Conclusion *string `json:"conclusion"` URL string `json:"url"` Before string `json:"before"` After string `json:"after"` @@ -82,7 +82,7 @@ type CheckSuitePayload struct { HeadBranch string `json:"head_branch"` HeadSHA string `json:"head_sha"` Status string `json:"status"` - Conclusion string `json:"conclusion"` + Conclusion *string `json:"conclusion"` URL string `json:"url"` Before string `json:"before"` After string `json:"after"` @@ -654,7 +654,7 @@ type PullRequestReviewPayload struct { CommitID string `json:"commit_id"` AuthorAssociation string `json:"author_association"` User User `json:"user"` - Body string `json:"body"` + Body *string `json:"body"` SubmittedAt time.Time `json:"submitted_at"` State string `json:"state"` HTMLURL string `json:"html_url"` @@ -705,7 +705,8 @@ type PullRequestReviewCommentPayload struct { Href string `json:"href"` } `json:"pull_request"` } `json:"_links"` - InReplyToID int64 `json:"in_reply_to_id"` //TODO this is not in the unmodified payload example on github docs + //TODO this is not in the payload example on github docs + // InReplyToID int64 `json:"in_reply_to_id"` PullRequestReviewID int64 `json:"pull_request_review_id"` } `json:"comment"` PullRequest ReviewPullRequest `json:"pull_request"` diff --git a/scrape/github.go b/scrape/github.go index acbfc78..1eae494 100644 --- a/scrape/github.go +++ b/scrape/github.go @@ -117,7 +117,7 @@ func main() { collected := collect() fmt.Printf("Found %s examle payloads. \n", len(collected)) root, _ := os.Getwd() - folder := path.Join(root, "tmp") + folder := path.Join(root, "testdata/github") if _, err := os.Stat(folder); os.IsNotExist(err) { os.Mkdir(folder, 0777) } diff --git a/testdata/github/check-run.json b/testdata/github/check-run.json index 40e7749..cbf639f 100755 --- a/testdata/github/check-run.json +++ b/testdata/github/check-run.json @@ -4,18 +4,18 @@ "id": 128620228, "node_id": "MDg6Q2hlY2tSdW4xMjg2MjAyMjg=", "head_sha": "ec26c3e57ca3a959ca5aad62de7213c562f8c821", - "external_id": "123", + "external_id": "", "url": "https://api.github.com/repos/Codertocat/Hello-World/check-runs/128620228", "html_url": "https://github.com/Codertocat/Hello-World/runs/128620228", "details_url": "https://octocoders.io", "status": "queued", - "conclusion": "success", + "conclusion": null, "started_at": "2019-05-15T15:21:12Z", - "completed_at": "2019-05-15T15:21:12Z", + "completed_at": null, "output": { - "title": "title", - "summary": "summary", - "text": "some text", + "title": null, + "summary": null, + "text": null, "annotations_count": 0, "annotations_url": "https://api.github.com/repos/Codertocat/Hello-World/check-runs/128620228/annotations" }, @@ -26,7 +26,7 @@ "head_branch": "changes", "head_sha": "ec26c3e57ca3a959ca5aad62de7213c562f8c821", "status": "queued", - "conclusion": "success", + "conclusion": null, "url": "https://api.github.com/repos/Codertocat/Hello-World/check-suites/118578147", "before": "6113728f27ae82c7b1a177c8d03f9e96e0adf246", "after": "ec26c3e57ca3a959ca5aad62de7213c562f8c821", @@ -105,7 +105,9 @@ "team_discussions": "write", "vulnerability_alerts": "read" }, - "events": [] + "events": [ + + ] }, "created_at": "2019-05-15T15:20:31Z", "updated_at": "2019-05-15T15:20:31Z" @@ -160,7 +162,9 @@ "team_discussions": "write", "vulnerability_alerts": "read" }, - "events": [] + "events": [ + + ] }, "pull_requests": [ { @@ -215,7 +219,7 @@ "site_admin": false }, "html_url": "https://github.com/Codertocat/Hello-World", - "description": "test", + "description": null, "fork": false, "url": "https://api.github.com/repos/Codertocat/Hello-World", "forks_url": "https://api.github.com/repos/Codertocat/Hello-World/forks", @@ -276,7 +280,7 @@ "archived": false, "disabled": false, "open_issues_count": 2, - "license": "licence", + "license": null, "forks": 1, "open_issues": 2, "watchers": 0, diff --git a/testdata/github/check-suite.json b/testdata/github/check-suite.json index cd61e65..2967604 100755 --- a/testdata/github/check-suite.json +++ b/testdata/github/check-suite.json @@ -85,7 +85,9 @@ "team_discussions": "write", "vulnerability_alerts": "read" }, - "events": [] + "events": [ + + ] }, "created_at": "2019-05-15T15:20:31Z", "updated_at": "2019-05-15T15:21:14Z", @@ -133,7 +135,7 @@ "site_admin": false }, "html_url": "https://github.com/Codertocat/Hello-World", - "description": "desc", + "description": null, "fork": false, "url": "https://api.github.com/repos/Codertocat/Hello-World", "forks_url": "https://api.github.com/repos/Codertocat/Hello-World/forks", diff --git a/testdata/github/meta.json b/testdata/github/meta.json index 4eee870..771ee41 100755 --- a/testdata/github/meta.json +++ b/testdata/github/meta.json @@ -40,7 +40,6 @@ "type": "User", "site_admin": false }, - "disabled": false, "private": false, "html_url": "https://github.com/Codertocat/Hello-World", "description": null, @@ -102,6 +101,7 @@ "forks_count": 0, "mirror_url": null, "archived": false, + "disabled": false, "open_issues_count": 1, "license": null, "forks": 0, diff --git a/testdata/github/pull-request-review-comment.json b/testdata/github/pull-request-review-comment.json index bf78498..4bc8b29 100755 --- a/testdata/github/pull-request-review-comment.json +++ b/testdata/github/pull-request-review-comment.json @@ -3,7 +3,6 @@ "comment": { "url": "https://api.github.com/repos/Codertocat/Hello-World/pulls/comments/284312630", "pull_request_review_id": 237895671, - "in_reply_to_id": 456545654, "id": 284312630, "node_id": "MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDI4NDMxMjYzMA==", "diff_hunk": "@@ -1 +1 @@\n-# Hello-World", @@ -89,10 +88,18 @@ "merged_at": null, "merge_commit_sha": "c4295bd74fb0f4fda03689c3df3f2803b658fd85", "assignee": null, - "assignees": [], - "requested_reviewers": [], - "requested_teams": [], - "labels": [], + "assignees": [ + + ], + "requested_reviewers": [ + + ], + "requested_teams": [ + + ], + "labels": [ + + ], "milestone": null, "commits_url": "https://api.github.com/repos/Codertocat/Hello-World/pulls/2/commits", "review_comments_url": "https://api.github.com/repos/Codertocat/Hello-World/pulls/2/comments", diff --git a/testdata/github/pull-request-review.json b/testdata/github/pull-request-review.json index 57931c5..06277bd 100755 --- a/testdata/github/pull-request-review.json +++ b/testdata/github/pull-request-review.json @@ -23,7 +23,7 @@ "type": "User", "site_admin": false }, - "body": "this is awesome", + "body": null, "commit_id": "ec26c3e57ca3a959ca5aad62de7213c562f8c821", "submitted_at": "2019-05-15T15:20:38Z", "state": "commented", @@ -80,21 +80,7 @@ "assignee": null, "assignees": [], "requested_reviewers": [], - "requested_teams": [ - { - "name": "go-team", - "id": 123456, - "node_id": "MDEwOlJlcG9zaXRvcnkxODY4NTMwMDI=", - "slug": "go-team", - "description": "test team", - "privacy": "i dont know", - "url": "https://api.github.com/users/Codertocat", - "html_url": "https://github.com/Codertocat", - "members_url": "http???", - "repositories_url": "http???", - "permission": "???" - } - ], + "requested_teams": [], "labels": [], "milestone": null, "commits_url": "https://api.github.com/repos/Codertocat/Hello-World/pulls/2/commits", diff --git a/testdata/github/pull-request.json b/testdata/github/pull-request.json index cbce502..6fd60cf 100755 --- a/testdata/github/pull-request.json +++ b/testdata/github/pull-request.json @@ -39,86 +39,19 @@ "closed_at": null, "merged_at": null, "merge_commit_sha": null, - "assignee": { - "login": "Codertocat6", - "id": 21031067, - "node_id": "MDQ6VXNlcjIxMDMxMDY3", - "avatar_url": "https://avatars1.githubusercontent.com/u/21031067?v=4", - "gravatar_id": "", - "url": "https://api.github.com/users/Codertocat", - "html_url": "https://github.com/Codertocat", - "followers_url": "https://api.github.com/users/Codertocat/followers", - "following_url": "https://api.github.com/users/Codertocat/following{/other_user}", - "gists_url": "https://api.github.com/users/Codertocat/gists{/gist_id}", - "starred_url": "https://api.github.com/users/Codertocat/starred{/owner}{/repo}", - "subscriptions_url": "https://api.github.com/users/Codertocat/subscriptions", - "organizations_url": "https://api.github.com/users/Codertocat/orgs", - "repos_url": "https://api.github.com/users/Codertocat/repos", - "events_url": "https://api.github.com/users/Codertocat/events{/privacy}", - "received_events_url": "https://api.github.com/users/Codertocat/received_events", - "type": "User", - "site_admin": false - }, + "assignee": null, "assignees": [ - { - "login": "Codertocat8", - "id": 21031067, - "node_id": "MDQ6VXNlcjIxMDMxMDY3", - "avatar_url": "https://avatars1.githubusercontent.com/u/21031067?v=4", - "gravatar_id": "", - "url": "https://api.github.com/users/Codertocat", - "html_url": "https://github.com/Codertocat", - "followers_url": "https://api.github.com/users/Codertocat/followers", - "following_url": "https://api.github.com/users/Codertocat/following{/other_user}", - "gists_url": "https://api.github.com/users/Codertocat/gists{/gist_id}", - "starred_url": "https://api.github.com/users/Codertocat/starred{/owner}{/repo}", - "subscriptions_url": "https://api.github.com/users/Codertocat/subscriptions", - "organizations_url": "https://api.github.com/users/Codertocat/orgs", - "repos_url": "https://api.github.com/users/Codertocat/repos", - "events_url": "https://api.github.com/users/Codertocat/events{/privacy}", - "received_events_url": "https://api.github.com/users/Codertocat/received_events", - "type": "User", - "site_admin": false - } + ], "requested_reviewers": [ - { - "login": "Codertocat5", - "id": 21031067, - "node_id": "MDQ6VXNlcjIxMDMxMDY3", - "avatar_url": "https://avatars1.githubusercontent.com/u/21031067?v=4", - "gravatar_id": "", - "url": "https://api.github.com/users/Codertocat", - "html_url": "https://github.com/Codertocat", - "followers_url": "https://api.github.com/users/Codertocat/followers", - "following_url": "https://api.github.com/users/Codertocat/following{/other_user}", - "gists_url": "https://api.github.com/users/Codertocat/gists{/gist_id}", - "starred_url": "https://api.github.com/users/Codertocat/starred{/owner}{/repo}", - "subscriptions_url": "https://api.github.com/users/Codertocat/subscriptions", - "organizations_url": "https://api.github.com/users/Codertocat/orgs", - "repos_url": "https://api.github.com/users/Codertocat/repos", - "events_url": "https://api.github.com/users/Codertocat/events{/privacy}", - "received_events_url": "https://api.github.com/users/Codertocat/received_events", - "type": "User", - "site_admin": false - } + ], "requested_teams": [ - { - "name": "go-team", - "id": 123456, - "node_id": "MDEwOlJlcG9zaXRvcnkxODY4NTMwMDI=", - "slug": "go-team", - "description": "test team", - "privacy": "i dont know", - "url": "https://api.github.com/users/Codertocat", - "html_url": "https://github.com/Codertocat", - "members_url": "http???", - "repositories_url": "http???", - "permission": "???" - } + + ], + "labels": [ + ], - "labels": [], "milestone": null, "commits_url": "https://api.github.com/repos/Codertocat/Hello-World/pulls/2/commits", "review_comments_url": "https://api.github.com/repos/Codertocat/Hello-World/pulls/2/comments",