csantanapr closed pull request #129: support trigger get and update for new 
deleteAfterFire param
URL: https://github.com/apache/incubator-openwhisk-package-alarms/pull/129
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/action/alarmWebAction.js b/action/alarmWebAction.js
index 478af06..55a6270 100644
--- a/action/alarmWebAction.js
+++ b/action/alarmWebAction.js
@@ -173,6 +173,7 @@ function main(params) {
                 };
                 if (doc.date) {
                     body.config.date = doc.date;
+                    body.config.deleteAfterFire = doc.deleteAfterFire;
                 }
                 else {
                     body.config.startDate = doc.startDate;
@@ -226,9 +227,9 @@ function main(params) {
                     if (params.deleteAfterFire) {
                         var deleteAfterFire = ('' + 
params.deleteAfterFire).trim().toLowerCase();
                         if (deleteAfterFireArray.indexOf(deleteAfterFire) === 
-1) {
-                            return common.sendError(400, 'deleteAfterFire 
parameter must be one of [false, true, rules].');
+                            return reject(common.sendError(400, 
'deleteAfterFire parameter must be one of [false, true, rules].'));
                         }
-                        newTrigger.deleteAfterFire = deleteAfterFire;
+                        updatedParams.deleteAfterFire = deleteAfterFire;
                     }
                 }
                 else {
@@ -251,7 +252,7 @@ function main(params) {
                                 new CronJob(params.cron, function() {});
                                 //validate cron granularity if 5 fields are 
allowed instead of 6
                                 if (params.limitCronFields && 
hasSecondsGranularity(params.cron)) {
-                                    return common.sendError(400, 'cron pattern 
is limited to 5 fields with 1 minute as the finest granularity');
+                                    return reject(common.sendError(400, 'cron 
pattern is limited to 5 fields with 1 minute as the finest granularity'));
                                 }
                             } catch (ex) {
                                 return reject(common.sendError(400, `cron 
pattern '${params.cron}' is not valid`));
@@ -290,7 +291,7 @@ function main(params) {
                 return db.disableTrigger(trigger._id, trigger, 0, 'updating');
             })
             .then(triggerID => {
-                return db.getTrigger(triggerID, false);
+                return db.getTrigger(triggerID);
             })
             .then(trigger => {
                 return db.updateTrigger(trigger._id, trigger, updatedParams, 
0);
diff --git a/tests/src/test/scala/system/health/AlarmsHealthFeedTests.scala 
b/tests/src/test/scala/system/health/AlarmsHealthFeedTests.scala
index e158f7a..200565a 100644
--- a/tests/src/test/scala/system/health/AlarmsHealthFeedTests.scala
+++ b/tests/src/test/scala/system/health/AlarmsHealthFeedTests.scala
@@ -376,11 +376,12 @@ class AlarmsHealthFeedTests
 
             // create trigger feed
             println(s"Creating trigger: $triggerName")
-            assetHelper.withCleaner(wsk.trigger, triggerName) {
+            assetHelper.withCleaner(wsk.trigger, triggerName, confirmDelete = 
false) {
                 (trigger, name) =>
                     trigger.create(name, feed = Some(s"$packageName/once"), 
parameters = Map(
                         "trigger_payload" -> payload,
-                        "date" -> futureDate.toJson))
+                        "date" -> futureDate.toJson,
+                        "deleteAfterFire" -> "true".toJson))
             }
 
             val actionName = s"$packageName/alarm"
@@ -399,6 +400,7 @@ class AlarmsHealthFeedTests
 
                             config should contain("date" -> futureDate.toJson)
                             config should contain("payload" -> payload)
+                            config should contain("deleteAfterFire" -> 
"true".toJson)
                     }
             }
 
@@ -412,7 +414,8 @@ class AlarmsHealthFeedTests
                 "lifecycleEvent" -> "UPDATE".toJson,
                 "authKey" -> wskProps.authKey.toJson,
                 "trigger_payload" ->updatedPayload,
-                "date" -> updatedFutureDate.toJson
+                "date" -> updatedFutureDate.toJson,
+                "deleteAfterFire" -> "rules".toJson
             ))
 
             withActivation(wsk.activation, updateRunAction) {
@@ -434,6 +437,7 @@ class AlarmsHealthFeedTests
 
                             config should contain("date" -> 
updatedFutureDate.toJson)
                             config should contain("payload" -> updatedPayload)
+                            config should contain("deleteAfterFire" -> 
"rules".toJson)
                     }
             }
     }


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to