Skip to content

Commit

Permalink
πŸ‘¨β€πŸ”¬ Add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
himynameisdave committed Dec 19, 2024
1 parent 1804196 commit 8d94364
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 0 deletions.
17 changes: 17 additions & 0 deletions pkg/labeler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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)
Expand Down
41 changes: 41 additions & 0 deletions test_data/create_pr_mergeable_not_clean_payload
Original file line number Diff line number Diff line change
@@ -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"
}
}

0 comments on commit 8d94364

Please sign in to comment.