joshua-peck / appenginetesting

Testing library for Go App Engine, giving you an appengine.Context fake that forwards to a dev_appserver.py child process.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

appenginetesting

Fork of gae-go-testing with a few minor changes:

  • renamed for nicer import syntax (that IDEA's Go Plugin won't highlight as an error)
  • added +build tags so that it compiles
  • simplified install instructions.

As of GAE 1.7.5, we now keep tags of the repository that are known to be compatible with each GAE release. If you are not using the latest GAE release, please use the associated tag.

Installation

Set environment variables :

$ export APPENGINE_SDK=/path/to/google_appengine
$ export PATH=$PATH:$APPENGINE_SDK

Before installing this library, you have to install appengine SDK. And copy appengine, appengine_internal and goprotobuf as followings :

$ export APPENGINE_SDK=/path/to/google_appengine
$ ln -s $APPENGINE_SDK/goroot/src/pkg/appengine
$ ln -s $APPENGINE_SDK/goroot/src/pkg/appengine_internal

There is some incompatibility when running the dev server like we do. You can fix this by changing the top of func init():

c := readConfig(os.Stdin)
instanceConfig.AppID = string(c.AppId)
instanceConfig.APIPort = int(*c.ApiPort)
instanceConfig.VersionID = string(c.VersionId)
instanceConfig.InstanceID = *c.InstanceId
instanceConfig.Datacenter = *c.Datacenter

It should be something like, values don't really matter:

instanceConfig.AppID = "testapp"
instanceConfig.APIPort = 0
instanceConfig.VersionID = "1.7.7"
instanceConfig.InstanceID = "instanceid"
instanceConfig.Datacenter = "instanceid"

This change hasn't produced any noticable issues in running the dev server.

This library can be installed as following :

$ go get github.com/icub3d/appenginetesting

Usage

The documentation has some basic examples. You can also find complete test examples within gorca/(*_test.go). Finally, context_test.go and recorder_test.go show an example of usage.

About

Testing library for Go App Engine, giving you an appengine.Context fake that forwards to a dev_appserver.py child process.

License:Other