You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openwhisk.apache.org by cs...@apache.org on 2017/10/04 18:14:06 UTC
[incubator-openwhisk-catalog] branch master updated: remove check
for channel param, update README, add test (#242)
This is an automated email from the ASF dual-hosted git repository.
csantanapr pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-openwhisk-catalog.git
The following commit(s) were added to refs/heads/master by this push:
new 0455d5b remove check for channel param, update README, add test (#242)
0455d5b is described below
commit 0455d5bc12b6d0bcf3dccd8bb15c8f6e6b09af0d
Author: Narine C <na...@gmail.com>
AuthorDate: Wed Oct 4 13:14:04 2017 -0500
remove check for channel param, update README, add test (#242)
---
packages/slack/README.md | 2 +-
packages/slack/post.js | 5 +----
tests/src/test/scala/packages/slack/SlackTests.scala | 13 +++++++++++++
3 files changed, 15 insertions(+), 5 deletions(-)
diff --git a/packages/slack/README.md b/packages/slack/README.md
index 7fe5692..a7101be 100644
--- a/packages/slack/README.md
+++ b/packages/slack/README.md
@@ -16,7 +16,7 @@ Creating a package binding with the `username`, `url`, and `channel` values is s
The `/whisk.system/slack/post` action posts a message to a specified Slack channel. The parameters are as follows:
- `url`: The Slack webhook URL.
-- `channel`: The Slack channel to post the message to.
+- `channel`: (optional) The Slack channel to post the message to.
- `username`: The name to post the message as.
- `text`: A message to post.
- `token`: (optional) A Slack [access token](https://api.slack.com/tokens). See [below](./catalog.md#using-the-slack-token-based-api) for more detail on the use of the Slack access tokens.
diff --git a/packages/slack/post.js b/packages/slack/post.js
index cb042b1..0be070a 100644
--- a/packages/slack/post.js
+++ b/packages/slack/post.js
@@ -6,7 +6,7 @@ var request = require('request');
/**
* Action to post to slack
* @param {string} url - Slack webhook url
- * @param {string} channel - Slack channel to post the message to
+ * @param {string} channel - (optional) Slack channel to post the message to
* @param {string} username - name to post the message as
* @param {string} text - message to post
* @param {string} icon_emoji - (optional) emoji to use as the icon for the message
@@ -89,9 +89,6 @@ function checkParams(params) {
else if (params.url === undefined) {
return 'No Webhook URL provided';
}
- else if (params.channel === undefined) {
- return 'No channel provided';
- }
else {
return undefined;
}
diff --git a/tests/src/test/scala/packages/slack/SlackTests.scala b/tests/src/test/scala/packages/slack/SlackTests.scala
index 28303e4..dbcdc40 100644
--- a/tests/src/test/scala/packages/slack/SlackTests.scala
+++ b/tests/src/test/scala/packages/slack/SlackTests.scala
@@ -53,4 +53,17 @@ class SlackTests extends TestHelpers
}
}
+ "Slack Package" should "print the object being sent to default channel in slack" in {
+ val run = wsk.action.invoke(slackAction, Map(
+ "username" -> username.toJson,
+ "text" -> text.toJson,
+ "url" -> url.toJson))
+ withActivation(wsk.activation, run) {
+ activation =>
+ activation.response.success shouldBe true
+ val logs = activation.logs.get.toString
+ logs should include("successfully sent")
+ }
+ }
+
}
--
To stop receiving notification emails like this one, please contact
['"commits@openwhisk.apache.org" <co...@openwhisk.apache.org>'].