The problem is though that your "app" isn't really your app. In other
words, your handlers and configuration in your .yaml file isn't used
to run your application when under aetest. If you simply export the
ModuleURL field in aetest, and you do just make a request to your app,
it's likely not going to be what you expected since the handlers are
wildly different.
Instead, I would recommend creating all of your http handlers to
accept an appengine.Context, *http.Request, and http.Response. That
way, you can pass them the aetest.Context and an
httptest.NewRecorder() and they're none the wiser.
http://stackoverflow.com/questions/19407343/how-can-i-unit-test-google-app-engine-go-http-handlers
-------------
type ContextHandler struct {
Real func(*appengine.Context, http.ResponseWriter, *http.Request)
}
func (f ContextHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
c := appengine.NewContext(r)
f.Real(c, w, r)
}
func myNewHandler(c appengine.Context, w http.ResponseWriter, r *http.Request) {
// do something
}
http.Handle("/myapi", ContextHandler(myNewHandler))
--------------
This works very conveniently when utilizing Matt Jibson's goon and appstats:
type ContextHandler func(*goon.Goon, http.ResponseWriter, *http.Request)
func (f ContextHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
c := appstats.NewContext(r)
f(goon.FromContext(c), w, r)
c.Save()
}
Then my http handlers can look like:
func logout(g *goon.Goon, w http.ResponseWriter, r *http.Request) {
// I no longer have to generate goon or appstats, I can just start
specific code to my handler
> --
> You received this message because you are subscribed to the Google Groups
> "google-appengine-go" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to
google-appengin...@googlegroups.com.
> For more options, visit
https://groups.google.com/d/optout.