From 81a37424245de1cd9dce2293a8a4adbf69dc10ef Mon Sep 17 00:00:00 2001 From: CJ Ketchum Date: Fri, 10 Apr 2020 13:55:48 -0700 Subject: [PATCH] Create dedicated test for draft PR events --- server/events/event_parser_test.go | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/server/events/event_parser_test.go b/server/events/event_parser_test.go index 5c2817e7b9..40509f1d7f 100644 --- a/server/events/event_parser_test.go +++ b/server/events/event_parser_test.go @@ -131,14 +131,6 @@ func TestParseGithubPullEvent(t *testing.T) { _, _, _, _, _, err = parser.ParseGithubPullEvent(&testEvent) ErrEquals(t, "sender.login is null", err) - // verify that draft PRs are treated as 'other' events - testEvent = deepcopy.Copy(PullEvent).(github.PullRequestEvent) - draftPR := true - testEvent.PullRequest.Draft = &draftPR - _, evType, _, _, _, err := parser.ParseGithubPullEvent(&testEvent) - Ok(t, err) - Equals(t, models.OtherPullEvent, evType) - actPull, evType, actBaseRepo, actHeadRepo, actUser, err := parser.ParseGithubPullEvent(&PullEvent) Ok(t, err) expBaseRepo := models.Repo{ @@ -168,6 +160,16 @@ func TestParseGithubPullEvent(t *testing.T) { Equals(t, models.User{Username: "user"}, actUser) } +func TestParseGithubPullEventFromDraft(t *testing.T) { + // verify that draft PRs are treated as 'other' events + testEvent := deepcopy.Copy(PullEvent).(github.PullRequestEvent) + draftPR := true + testEvent.PullRequest.Draft = &draftPR + _, evType, _, _, _, err := parser.ParseGithubPullEvent(&testEvent) + Ok(t, err) + Equals(t, models.OtherPullEvent, evType) +} + func TestParseGithubPullEvent_EventType(t *testing.T) { cases := []struct { action string