Skip to content

Commit

Permalink
#1248 Github labeled and unlabeled action handled
Browse files Browse the repository at this point in the history
  • Loading branch information
amihaiemil committed Oct 14, 2021
1 parent 8f27722 commit bd06f8c
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,10 @@ public String type() {
resolved = Type.NEW_ISSUE;
} else if ("reopened".equalsIgnoreCase(act)) {
resolved = Type.REOPENED_ISSUE;
} else if ("labeled".equalsIgnoreCase(act)) {
resolved = Type.LABEL;
} else if ("unlabeled".equalsIgnoreCase(act)) {
resolved = Type.LABEL;
} else {
resolved = type;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,70 @@ public void returnsReopenedIssueType() {
);
}

/**
* GithubWebhookEvent can return the labeled Issue type on labeling
* an Issue.
*/
@Test
public void returnsLabelOnIssueLabeledAction() {
final Project project = Mockito.mock(Project.class);
final Event event = new GithubWebhookEvent(
project, "issues", "{\"action\":\"labeled\"}"
);
MatcherAssert.assertThat(
event.type(),
Matchers.equalTo(Event.Type.LABEL)
);
}

/**
* GithubWebhookEvent can return the labeled Issue type on unlabeling
* an Issue.
*/
@Test
public void returnsLabelOnIssueUnlabeledAction() {
final Project project = Mockito.mock(Project.class);
final Event event = new GithubWebhookEvent(
project, "issues", "{\"action\":\"unlabeled\"}"
);
MatcherAssert.assertThat(
event.type(),
Matchers.equalTo(Event.Type.LABEL)
);
}

/**
* GithubWebhookEvent can return the labeled PR type on labeling
* an Issue.
*/
@Test
public void returnsLabelOnPullRequestLabeledAction() {
final Project project = Mockito.mock(Project.class);
final Event event = new GithubWebhookEvent(
project, "pull_request", "{\"action\":\"labeled\"}"
);
MatcherAssert.assertThat(
event.type(),
Matchers.equalTo(Event.Type.LABEL)
);
}

/**
* GithubWebhookEvent can return the labeled PR type on unlabeling
* an Issue.
*/
@Test
public void returnsLabelOnPullRequestUnlabeledAction() {
final Project project = Mockito.mock(Project.class);
final Event event = new GithubWebhookEvent(
project, "pull_request", "{\"action\":\"unlabeled\"}"
);
MatcherAssert.assertThat(
event.type(),
Matchers.equalTo(Event.Type.LABEL)
);
}

/**
* GithubWebhookEvent can return the REPO_RENAMED type.
*/
Expand Down

0 comments on commit bd06f8c

Please sign in to comment.