Dave.
We discussed the idea of mocking up context call like this:
c.Call("datastore_v3", "Get", req, res, nil)
by implementing a different Context interface:
http://code.google.com/p/appengine-go/source/browse/appengine/appengine.go
Do you think it would be practicable ?
--
Johan Euphrosine (proppy)
Developer Programs Engineer
Google Developer Relations
> When we discussed this with Rodrigo on #appengine,
>
> We discussed the idea of mocking up context call like this:
> c.Call("datastore_v3", "Get", req, res, nil)
>
> by implementing a different Context interface:
> http://code.google.com/p/appengine-go/source/browse/appengine/appengine.go
>
> Do you think it would be practicable ?
It's practical, but not a particularly useful way to test your code.
The test would be covering implementation details of the
appengine/datastore package. A better approach would be to make a tiny
interface for the aspects of appengine/datastore that you use, have
one real implementation of it that just plumbs through to
appengine/datastore, and then use that interface in your code. Then
you can mock out that interface in your tests.
Dave.
Maybe an approach similar to appengine.ext.testbed for python is also possible:
http://code.google.com/appengine/docs/python/tools/localunittesting.html
http://code.google.com/p/googleappengine/source/browse/trunk/python/google/appengine/ext/testbed/__init__.py
But that would mean require implementing datastore stub similar to
what is in the python SDK:
http://code.google.com/p/googleappengine/source/browse/trunk/python/google/appengine/api/datastore_file_stub.py
You don't have to write a functional mock (called a "fake" in some
circles); you could just have a stub implementation, or use something
like gomock (http://code.google.com/p/gomock/).
If you care enough about the behaviour to warrant a functional mock,
you'd be better off starting up the dev_appserver, because there's a
surprising amount of complexity and edge cases to consider for
something like datastore.
Dave.
Using dev_appserver is what I want to do. Brad mentions "run App
Engine tests in a child process...", but I'm a little lost how this
would be done. Can you give me a more detailed hint about how this
would work?
On Oct 24, 10:35 am, Ugorji Nwoke wrote:
> Someone else can probably give a more detailed response, but in summary
> (from looking through the GO Code):
> hdr = http.Header{}
> header.Add("X-AppEngine-Inbound-AppId", "anything")
> req := &http.Request { Header: hdr }
>
> And pass that in.
Thanks. Can someone confirm that this is this would be enough to for
production?
Basically, I want to know how to get the App Engine
context from a rpc method (need the current http.Request from inside
the method).
Brad,The Go GAE testing process is unclear to me. My Go application includes several packages mine as well as 3rd party. All of which reside in a common directory, the GAE SDK compiles and runs these on demand without any Makefiles. Moreover, the GAE SDK does not install these packages to the SDK directory. In order to test, do I need to install Go separately and install each of the packages to the separate Go directory. Also, do I need to write makes files in order to test? Basically, I'm a bit confused regarding the best practices for testing GAE applications and how it relates to the SDK. Moreover, assuming additional files are needed for testing, what is the best way to keep these from being uploaded to production.Jeff