Skip to content

Commit

Permalink
Add check description to Slack messages, if present
Browse files Browse the repository at this point in the history
  • Loading branch information
neilprosser committed Mar 6, 2015
1 parent 2723221 commit 7058dea
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -119,16 +119,24 @@ public String apply(Alert input) {
return String.format("%s = %s", input.getTarget(), input.getValue().toString());
}
}));

String channel = subscription.getTarget().contains("!") ? "<!channel>" : "";

String description;
if (StringUtils.isNotBlank(check.getDescription())) {
description = String.format("\n> %s", check.getDescription());
} else {
description = "";
}

final String state = check.getState().toString();

return String.format("%s%s %s [%s]\n```\n%s\n```\n#%s %s",
return String.format("%s*%s* %s [%s]%s\n```\n%s\n```\n#%s %s",
Iterables.get(emojis, check.getState().ordinal(), ""),
state,
check.getName(),
url,
description,
alertsString,
state.toLowerCase(Locale.getDefault()),
channel
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ public void basicSlackTest() {
assertThat(content, Matchers.containsString("token="));
assertThat(content, Matchers.containsString("&channel=target"));
assertThat(content, not(Matchers.containsString(encode("<!channel>"))));
assertThat(content, Matchers.containsString(encode("ERROR test-check")));
assertThat(content, Matchers.containsString(encode("*ERROR* test-check")));
assertThat(content, Matchers.containsString(encode("/#/checks/123")));
assertThat(content, Matchers.containsString("&username=Seyren"));
assertThat(content, Matchers.containsString("&icon_url="));
Expand Down Expand Up @@ -162,7 +162,7 @@ public void mentionChannelWhenTargetContainsExclamationTest() {
assertThat(content, Matchers.containsString("token="));
assertThat(content, Matchers.containsString("&channel=target"));
assertThat(content, Matchers.containsString(encode("<!channel>")));
assertThat(content, Matchers.containsString(encode("ERROR test-check")));
assertThat(content, Matchers.containsString(encode("*ERROR* test-check")));
assertThat(content, Matchers.containsString(encode("/#/checks/123")));
assertThat(content, Matchers.containsString("&username=Seyren"));
assertThat(content, Matchers.containsString("&icon_url="));
Expand Down

0 comments on commit 7058dea

Please sign in to comment.