3 ms·
Use regular "go test" for unit testing. If you're using metadata inside your function (e.g., to extract an event ID) you can use metadata.NewContext to pass int
by chrisbroadfoot 8y ago
Use regular "go test" for unit testing. If you're using metadata inside your function (e.g., to extract an event ID) you can use metadata.NewContext to pass into your function while testing:
https://godoc.org/cloud.google.com/go/functions/metadata#NewContext https://godoc.org/cloud.google.com/go/functions/metadata#New...
If you just want to execute your function, create another package main and start an HTTP server, as you'd normally do.
There are some examples on this page:
https://cloud.google.com/functions/docs/bestpractices/testing#functions-prepare-environment-go https://cloud.google.com/functions/docs/bestpractices/testin...
We're thinking about ways to improve the local development/testing story, and are keen to hear any ideas/feedback.
Disclaimer: I work at Google, and worked on this product.
- gobuildship 8y agoJust do what Azure does with functions. Have used their VS Code local debug and "just worked" out of the box