Reputation: 1619
I have my appengine SDK in ~/Applications/google_appengine
In Eclipse, i've got an external tool setup to run the dev server. It's pointed at:
~/Application/google_appengine/dev_appserver.py
Also in Eclipse (Go Preferences), I've set the GOROOT to point to
~/Application/google_appengine/goroot
Now, I'm trying to run some unit tests for my project. If I use my regular go installation (not the appengine one), I get this error:
../../context/context.go:4:2: cannot find package "appengine" in any of:
/usr/local/go/src/pkg/appengine (from $GOROOT)
/Users/home/src/go/foodbox/src/appengine (from $GOPATH)
../../context/data.go:4:2: cannot find package "appengine/datastore" in any of:
/usr/local/go/src/pkg/appengine/datastore (from $GOROOT)
/Users/home/src/go/foodbox/src/appengine/datastore (from $GOPATH)
../../context/context.go:5:2: cannot find package "appengine/user" in any of:
/usr/local/go/src/pkg/appengine/user (from $GOROOT)
/Users/home/src/go/foodbox/src/appengine/user (from $GOPATH)
If i use the appengine go, I get this one:
load cmd/cgo: package cmd/cgo: no Go source files in /Users/home/Application/google_appengine/goroot/src/cmd/cgo
It seems like the default installation can't find the appengine packages (I guess that's not surprising). I'm not sure what the problem is when I use the appengine go tools. Can anyone tell me how to get this to work?
Thanks!
Upvotes: 3
Views: 1214
Reputation: 2198
See the docs:
http://blog.golang.org/appengine-dec2013
Check out the section called "Local Unit Testing"
I think what you are looking for is goapp test
that comes with the sdk.
Upvotes: 0
Reputation: 16615
It may be worth mentioning that the appengine/aetest
package is now included in the SDK, since 1.8.6. See the documentation.
Basically you get an appengine.Context
that can be used in your tests, similar to icub3d/appenginetesting.
Quoting the example from the docs:
import (
"testing"
"appengine/aetest"
)
func TestMyFunction(t *testing.T) {
c, err := aetest.NewContext(nil)
if err != nil {
t.Fatal(err)
}
defer c.Close()
// Run code and tests requiring the appengine.Context using c.
}
Upvotes: 5