Skip to content

Commit ca51a84

Browse files
committed
Display appropriate message when an activation ID is not returned from a trigger fire
1 parent 0807de2 commit ca51a84

3 files changed

Lines changed: 37 additions & 7 deletions

File tree

commands/trigger.go

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,8 @@ var triggerFireCmd = &cobra.Command{
117117

118118
// TODO get rid of these global modifiers
119119
Client.Namespace = qualifiedName.GetNamespace()
120-
trigResp, _, err := Client.Triggers.Fire(qualifiedName.GetEntityName(), parameters)
120+
121+
trigResp, resp, err := Client.Triggers.Fire(qualifiedName.GetEntityName(), parameters)
121122
if err != nil {
122123
whisk.Debug(whisk.DbgError, "Client.Triggers.Fire(%s, %#v) failed: %s\n", qualifiedName.GetEntityName(), parameters, err)
123124
errStr := wski18n.T("Unable to fire trigger '{{.name}}': {{.err}}",
@@ -127,13 +128,24 @@ var triggerFireCmd = &cobra.Command{
127128
return werr
128129
}
129130

131+
if resp.StatusCode == 204 {
132+
fmt.Fprintf(color.Output,
133+
wski18n.T("trigger /{{.namespace}}/{{.name}} did not fire as it is not associated with an active rule(s)\n",
134+
map[string]interface{}{
135+
"namespace": boldString(qualifiedName.GetNamespace()),
136+
"name": boldString(qualifiedName.GetEntityName())}))
137+
138+
return nil
139+
}
140+
130141
fmt.Fprintf(color.Output,
131142
wski18n.T("{{.ok}} triggered /{{.namespace}}/{{.name}} with id {{.id}}\n",
132143
map[string]interface{}{
133144
"ok": color.GreenString("ok:"),
134145
"namespace": boldString(qualifiedName.GetNamespace()),
135146
"name": boldString(qualifiedName.GetEntityName()),
136147
"id": boldString(trigResp.ActivationId)}))
148+
137149
return nil
138150
},
139151
}

tests/src/test/scala/system/basic/WskCliBasicTests.scala

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -195,12 +195,12 @@ class WskCliBasicTests extends TestHelpers with WskTestHelpers {
195195
}
196196

197197
val stdout = wsk.action.get(name).stdout
198-
stdout should not include regex(""""key": "a"""")
199-
stdout should not include regex(""""value": "A"""")
200-
stdout should include regex (""""key": "b""")
201-
stdout should include regex (""""value": "B"""")
202-
stdout should include regex (""""publish": false""")
203-
stdout should include regex (""""version": "0.0.2"""")
198+
stdout should not include (""""key": "a"""")
199+
stdout should not include (""""value": "A"""")
200+
stdout should include (""""key": "b""")
201+
stdout should include (""""value": "B"""")
202+
stdout should include (""""publish": false""")
203+
stdout should include (""""version": "0.0.2"""")
204204
wsk.action.list().stdout should include(name)
205205
}
206206

@@ -749,6 +749,20 @@ class WskCliBasicTests extends TestHelpers with WskTestHelpers {
749749
}
750750
}
751751

752+
it should "display proper error when trigger is not associated with active rule" in withAssetCleaner(wskprops) {
753+
val triggerName = withTimestamp("noRuleTrigger")
754+
755+
(wp, assetHelper) =>
756+
assetHelper.withCleaner(wsk.trigger, triggerName) { (trigger, _) =>
757+
trigger.create(triggerName)
758+
}
759+
760+
val rr = wsk.trigger.fire(triggerName)
761+
val ns = wsk.namespace.whois()
762+
763+
rr.stdout should include regex(s"trigger /.*/$triggerName did not fire as it is not associated with an active rule\\(s\\)")
764+
}
765+
752766
behavior of "Wsk Rule CLI"
753767

754768
it should "create rule, get rule, update rule and list rule" in withAssetCleaner(wskprops) { (wp, assetHelper) =>

wski18n/resources/en_US.all.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -625,6 +625,10 @@
625625
"id": "{{.ok}} triggered /{{.namespace}}/{{.name}} with id {{.id}}\n",
626626
"translation": "{{.ok}} triggered /{{.namespace}}/{{.name}} with id {{.id}}\n"
627627
},
628+
{
629+
"id": "trigger /{{.namespace}}/{{.name}} did not fire as it is not associated with an active rule(s)\n",
630+
"translation": "trigger /{{.namespace}}/{{.name}} did not fire as it is not associated with an active rule(s)\n"
631+
},
628632
{
629633
"id": "create new trigger",
630634
"translation": "create new trigger"

0 commit comments

Comments
 (0)