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/11/17 21:52:15 UTC

[incubator-openwhisk-client-js] branch master updated: support feed trigger update (#88)

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-client-js.git


The following commit(s) were added to refs/heads/master by this push:
     new 132f5b3  support feed trigger update (#88)
132f5b3 is described below

commit 132f5b32139642130b5b4645e13cb8bf59c1660d
Author: Adnan Baruni <ab...@users.noreply.github.com>
AuthorDate: Fri Nov 17 15:52:13 2017 -0600

    support feed trigger update (#88)
    
    * support feed trigger update
    
    * update test description
---
 README.md                      |  5 +++--
 lib/feeds.js                   |  4 ++++
 test/integration/feeds.test.js | 11 +++++++----
 test/unit/feeds.test.js        | 22 ++++++++++++++++++++++
 4 files changed, 36 insertions(+), 6 deletions(-)

diff --git a/README.md b/README.md
index afd150e..3f36dec 100644
--- a/README.md
+++ b/README.md
@@ -247,7 +247,7 @@ ow.triggers.get({name: '...'})
 ow.rules.get({name: '...'})
 ow.namespaces.get({name: '...'})
 ow.packages.get({name: '...'})
-ow.feeds.get({name: '...'})
+ow.feeds.get({name: '...', trigger: '...'})
 ```
 
 The following optional parameters are supported:
@@ -415,10 +415,11 @@ ow.rules.disable({name: '...'})
 The following optional parameters are supported:
 - `namespace` - set custom namespace for endpoint
 
-### create feeds
+### create & update feeds
 
 ```javascript
 ow.feeds.create({feedName: '...', trigger: '...'})
+ow.feeds.update({feedName: '...', trigger: '...'})
 ```
 
 The following optional parameters are supported:
diff --git a/lib/feeds.js b/lib/feeds.js
index f8cdc28..1ecc151 100644
--- a/lib/feeds.js
+++ b/lib/feeds.js
@@ -25,6 +25,10 @@ class Feeds {
     return this.feed('READ', options)
   }
 
+  update (options) {
+    return this.feed('UPDATE', options)
+  }
+
   feed (event, options) {
     if (!this.feed_name(options)) {
       throw new Error(messages.MISSING_FEED_NAME_ERROR)
diff --git a/test/integration/feeds.test.js b/test/integration/feeds.test.js
index 1ebd7b8..d2ea95c 100644
--- a/test/integration/feeds.test.js
+++ b/test/integration/feeds.test.js
@@ -23,7 +23,7 @@ envParams.forEach(key => {
 const NAMESPACE = process.env.__OW_NAMESPACE
 var tempTest = Utils.getInsecureFlag() ? test.skip : test;
 
-tempTest('create and delete a feed', t => {
+tempTest('create, get, update, and delete a feed', t => {
   const errors = err => {
     console.log(err)
     t.fail()
@@ -42,9 +42,12 @@ tempTest('create and delete a feed', t => {
       t.is(get_result.response.success, true)
       return feeds.delete(feed_params).then(feed_result => {
         t.is(feed_result.response.success, true)
-        return triggers.delete({triggerName: 'sample_feed_trigger'}).then(() => {
-          t.pass()
-        })
+        return feeds.update(feed_params).then(update_result => {
+          t.is(feed_result.response.success, false) // alarms does not currently support update, hence should fail
+          return triggers.delete({triggerName: 'sample_feed_trigger'}).then(() => {
+            t.pass()
+          })
+        }).catch(errors)
       }).catch(errors)
     }).catch(errors)
   }).catch(errors)
diff --git a/test/unit/feeds.test.js b/test/unit/feeds.test.js
index d68ef6f..005f3ec 100644
--- a/test/unit/feeds.test.js
+++ b/test/unit/feeds.test.js
@@ -228,6 +228,28 @@ test('should be able to get feed', t => {
   return feeds.get({name: feed_name, trigger: trigger_name})
 })
 
+test('should be able to update feed', t => {
+  const feed_name = 'feed_name'
+  const api_key = 'username:password'
+  const trigger_name = '/trigger_ns/trigger_name'
+  const client = {}
+  client.options = { api_key }
+
+  const ns = '_'
+  const feeds = new Feeds(client)
+
+  client.request = (method, path, options) => {
+    t.is(method, 'POST')
+    t.is(path, `namespaces/${ns}/actions/${feed_name}`)
+    t.deepEqual(options.qs, {blocking: true})
+    t.deepEqual(options.body, {authKey: client.options.api_key, lifecycleEvent: 'UPDATE', triggerName: `${trigger_name}`})
+  }
+
+  t.plan(4)
+
+  return feeds.update({name: feed_name, trigger: trigger_name})
+})
+
 test('should throw errors without trigger parameter ', t => {
   const ns = '_'
   const client = { options: {} }

-- 
To stop receiving notification emails like this one, please contact
['"commits@openwhisk.apache.org" <co...@openwhisk.apache.org>'].