Skip to content

Commit

Permalink
Create dedicated test for draft PR events
Browse files Browse the repository at this point in the history
  • Loading branch information
cket committed Apr 10, 2020
1 parent d41d0f4 commit 81a3742
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions server/events/event_parser_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 81a3742

Please sign in to comment.