Reputation:
I moved a project from the bundled appengine/*
imports to google.golang.org/appengine/*
. My test cases still rely on appengine/aetest
. Unfortunately the aetest
package hasn't been ported yet to google.golang.org/appengine/aetest
, which is why I get compile errors because it returns a different context type (appengine.Context
instead of x/net/context.Context
) as the bundled packages.
I also can't create a new context, because I'd need a http.Request
object for that.
Is there a way to work around this?
Upvotes: 2
Views: 378
Reputation: 677
Something like this should work now:
import (
"google.golang.org/appengine"
"google.golang.org/appengine/aetest"
)
func MyTest(t *testing.T) {
inst, err := aetest.NewInstance(nil)
if err != nil {
tb.Fatal(err)
}
req, err := inst.NewRequest("GET", "http://www.whatever.com/", nil)
if err != nil {
tb.Fatal(err)
}
ctx := appengine.NewContext(req)
...
}
Upvotes: 2