Reputation: 115
I am testing node js app using mocha and assert.
Get sample code from this link
I deploy helloBackground function in local and also in gcloud succesfullly
then I try to execute mocha test case.
also tried all way to call gcloud functions describe here
Then execute below command in CMD
functions call helloBackground --data '{\"name\": \"John\"}'
This should return "Hello John!" in command prompt.
but I receive an error as
Error: TypeError: Cannot read property 'name' of undefined
Please let me know how to pass proper data in CMD to test.
Thank you in advance.
Upvotes: 0
Views: 160
Reputation: 350
Looking at your error message, it is most likely caused by the trigger argument you used when you deployed the app. The helloBackground
function is a Background Function, and instead of --trigger-http, you should use a background function trigger.
For example: $ gcloud functions deploy helloBackground --runtime nodejs6 --trigger-resource you_bucket_name --trigger-event google.storage.object.finalize
You would need to create an empty .txt file in the same directory of your app and upload it to Cloud Storage
$ gsutil cp test.txt gs://[ the name of your cloud storage bucket ]
And you can run the app again.
You will find more explanation on the type of functions here And you can follow this well documented tutorial on Cloud Storage here
Upvotes: 1