diff --git a/pkg/labeler_test.go b/pkg/labeler_test.go index 9c9ad96..5503ae8 100644 --- a/pkg/labeler_test.go +++ b/pkg/labeler_test.go @@ -1049,6 +1049,22 @@ func TestHandleEvent(t *testing.T) { initialLabels: []string{"Meh"}, expectedLabels: []string{"Meh", "ShouldAppear"}, }, + { + event: "pull_request", + payloads: []string{"create_pr_mergeable_not_clean"}, + name: "Don't add label when PR is mergeable but state is not clean", + config: LabelerConfigV1{ + Version: 1, + Labels: []LabelMatcher{ + { + Label: "CanMerge", + Mergeable: "True", + }, + }, + }, + initialLabels: []string{}, + expectedLabels: []string{}, + }, } for _, tc := range testCases { @@ -1059,6 +1075,7 @@ func TestHandleEvent(t *testing.T) { fmt.Printf("Test `%s`: failed to load %s\n", tc.name, file) t.Fatal(err) } + fmt.Printf("Loaded payload: %s\n", string(payload)) fmt.Printf("--> TEST: %s \n", tc.name) l := NewTestLabeler(t, tc) diff --git a/test_data/create_pr_mergeable_not_clean_payload b/test_data/create_pr_mergeable_not_clean_payload new file mode 100644 index 0000000..cdc7c11 --- /dev/null +++ b/test_data/create_pr_mergeable_not_clean_payload @@ -0,0 +1,41 @@ +{ + "action": "opened", + "number": 1, + "pull_request": { + "number": 1, + "state": "open", + "locked": false, + "title": "Update test", + "user": { + "login": "srvaroa", + "type": "User" + }, + "body": "Test PR", + "base": { + "repo": { + "name": "labeler", + "owner": { + "login": "srvaroa" + } + } + }, + "created_at": "2019-05-24T22:03:59Z", + "updated_at": "2019-05-24T22:03:59Z", + "closed_at": null, + "merged_at": null, + "merge_commit_sha": null, + "assignee": null, + "assignees": [], + "requested_reviewers": [], + "requested_teams": [], + "labels": [], + "milestone": null, + "commits": 1, + "additions": 1, + "deletions": 1, + "changed_files": 1, + "mergeable": true, + "mergeable_state": "blocked", + "author_association": "OWNER" + } +}