4 ms·
IIRC only the Node.js runtime has the ability to be emulated locally. Is this still the case? If I wanted to test my function locally, how would I go about doin
by dstaley 8y ago
IIRC only the Node.js runtime has the ability to be emulated locally. Is this still the case? If I wanted to test my function locally, how would I go about doing that?
- chrisbroadfoot 8y agoUse 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