This is an automated email from the ASF dual-hosted git repository.

mrutkowski pushed a commit to branch master
in repository 
https://gitbox.apache.org/repos/asf/incubator-openwhisk-wskdeploy.git


The following commit(s) were added to refs/heads/master by this push:
     new 606f8b7  Fix an issue of deploymentreader and add a unit test (#542)
606f8b7 is described below

commit 606f8b72030ded6f8d8692d3afa4412bdfcc2ac4
Author: Ying Chun Guo <guoyi...@cn.ibm.com>
AuthorDate: Tue Sep 26 10:02:58 2017 +0800

    Fix an issue of deploymentreader and add a unit test (#542)
---
 deployers/deploymentreader.go                  |  6 ++---
 deployers/deploymentreader_test.go             | 35 ++++++++++++++++++++++++++
 tests/dat/deployment-deploymentreader-test.yml | 18 +++++++++++++
 3 files changed, 56 insertions(+), 3 deletions(-)

diff --git a/deployers/deploymentreader.go b/deployers/deploymentreader.go
index 9a0e145..dc96a6c 100644
--- a/deployers/deploymentreader.go
+++ b/deployers/deploymentreader.go
@@ -110,7 +110,7 @@ func (reader *DeploymentReader) 
bindPackageInputsAndAnnotations() {
                        serviceDeployPack.Package.Parameters = keyValArr
                }
 
-               keyValArr = keyValArr[:0]
+               keyValArr = make(whisk.KeyValueArr, 0)
 
                if len(pack.Annotations) > 0 {
                        for name, input := range pack.Annotations {
@@ -180,7 +180,7 @@ func (reader *DeploymentReader) 
bindActionInputsAndAnnotations() {
                                }
                        }
 
-                       keyValArr = keyValArr[:0]
+                       keyValArr = make(whisk.KeyValueArr, 0)
 
                        if len(action.Annotations) > 0 {
                                for name, input := range action.Annotations {
@@ -249,7 +249,7 @@ func (reader *DeploymentReader) 
bindTriggerInputsAndAnnotations() {
                                }
                        }
 
-                       keyValArr = keyValArr[:0]
+                       keyValArr = make(whisk.KeyValueArr, 0)
 
                        if len(trigger.Annotations) > 0 {
                                for name, input := range trigger.Annotations {
diff --git a/deployers/deploymentreader_test.go 
b/deployers/deploymentreader_test.go
index 97fe936..c3e92aa 100644
--- a/deployers/deploymentreader_test.go
+++ b/deployers/deploymentreader_test.go
@@ -22,6 +22,7 @@ package deployers
 import (
        "github.com/stretchr/testify/assert"
        "testing"
+       "github.com/apache/incubator-openwhisk-client-go/whisk"
 )
 
 var sd *ServiceDeployer
@@ -50,3 +51,37 @@ func TestDeployerCheck(t *testing.T) {
        // The system will exit thus the test will fail.
        // sd.Check()
 }
+
+func TestDeploymentReader_bindTrigger(t *testing.T) {
+       //init variables
+       sDeployer := NewServiceDeployer()
+       sDeployer.DeploymentPath = 
"../tests/dat/deployment-deploymentreader-test.yml"
+       sDeployer.Deployment.Triggers["locationUpdate"] = new(whisk.Trigger)
+
+       //parse deployment and bind triggers input and annotation
+       dReader := NewDeploymentReader(sDeployer)
+       dReader.HandleYaml()
+       dReader.bindTriggerInputsAndAnnotations()
+
+       trigger := sDeployer.Deployment.Triggers["locationUpdate"]
+       for _, param := range trigger.Parameters {
+               switch param.Key {
+               case "name":
+                       assert.Equal(t, "Bernie", param.Value, "Failed to set 
inputs")
+               case "place":
+                       assert.Equal(t, "DC", param.Value, "Failed to set 
inputs")
+               default:
+                       assert.Fail(t, "Failed to get inputs key")
+
+               }
+       }
+       for _, annos := range trigger.Annotations {
+               switch annos.Key {
+               case "bbb":
+                       assert.Equal(t, "this is an annotation", annos.Value, 
"Failed to set annotations")
+               default:
+                       assert.Fail(t, "Failed to get annotation key")
+
+               }
+       }
+}
diff --git a/tests/dat/deployment-deploymentreader-test.yml 
b/tests/dat/deployment-deploymentreader-test.yml
new file mode 100644
index 0000000..3fca66c
--- /dev/null
+++ b/tests/dat/deployment-deploymentreader-test.yml
@@ -0,0 +1,18 @@
+application:
+  name: AppWithTriggerRule
+  packages:
+    triggerrule:
+      actions:
+        greeting:
+          inputs:
+            name: Amy
+            place: Paris
+          annotations:
+            aaa: this is an annotation
+      triggers:
+        locationUpdate:
+          inputs:
+            name: Bernie
+            place: DC
+          annotations:
+            bbb: this is an annotation

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

Reply via email to