From 7ac3d502e210f381c67fd69a815ca38c97106e04 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rudstr=C3=B8m?= Date: Tue, 15 Oct 2019 20:54:15 +0200 Subject: [PATCH] added missing PublicPayload test --- github/payload.go | 5 +++-- github/payload_test.go | 7 +++++++ scrape/github.go | 2 +- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/github/payload.go b/github/payload.go index 6f82ada..bbd26a3 100644 --- a/github/payload.go +++ b/github/payload.go @@ -472,8 +472,9 @@ type ProjectPayload struct { // PublicPayload contains the information for GitHub's public hook event type PublicPayload struct { - Repository Repository `json:"repository"` - Sender User `json:"sender"` + Repository Repository `json:"repository"` + Sender User `json:"sender"` + Installation Installation `json:"installation"` } // PullRequestPayload contains the information for GitHub's pull_request hook event diff --git a/github/payload_test.go b/github/payload_test.go index ca052d0..3e347a9 100644 --- a/github/payload_test.go +++ b/github/payload_test.go @@ -154,6 +154,11 @@ func TestPayloads(t *testing.T) { filename: "project.json", typ: &ProjectPayload{}, }, + { + name: "PublicPayload", + filename: "public.json", + typ: &PublicPayload{}, + }, { name: "PullRequestReviewCommentPayload", filename: "pull-request-review-comment.json", @@ -221,8 +226,10 @@ func TestPayloads(t *testing.T) { t.Parallel() payload, err := ioutil.ReadFile(pth.Join("../testdata/github", tc.filename)) assert.NoError(err) + parsedPayload, err := ParsePayload(string(payload), tc.typ) assert.NoError(err) + a, _ := jd.ReadJsonString(string(payload)) b, _ := jd.ReadJsonString(parsedPayload) diff := a.Diff(b).Render() diff --git a/scrape/github.go b/scrape/github.go index 1eae494..f251111 100644 --- a/scrape/github.go +++ b/scrape/github.go @@ -115,7 +115,7 @@ func write(folder string, example ExamplePayload) error { } func main() { collected := collect() - fmt.Printf("Found %s examle payloads. \n", len(collected)) + fmt.Printf("Found %d examle payloads. \n", len(collected)) root, _ := os.Getwd() folder := path.Join(root, "testdata/github") if _, err := os.Stat(folder); os.IsNotExist(err) {