Skip to content

Commit

Permalink
added missing PublicPayload test
Browse files Browse the repository at this point in the history
  • Loading branch information
henrikrudstrom committed Oct 15, 2019
1 parent 7f580b1 commit 7ac3d50
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
5 changes: 3 additions & 2 deletions github/payload.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 7 additions & 0 deletions github/payload_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion scrape/github.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 7ac3d50

Please sign in to comment.