「goapp test」出现了意料之外的错误,让我感到很困扰
如果你对这个错误感到敏感,请留下评论。
环境
-
- Google App Engine SDK のインストール
-
- Go のインストール
- Git のインストール
>goapp version
go version go1.6.3 (appengine-1.9.46) windows/amd64
>go version
go version go1.7.1 windows/amd64
>git version
git version 2.11.0.windows.3
package sample
import (
"testing"
"google.golang.org/appengine/aetest"
"google.golang.org/appengine/memcache"
)
func TestFoo(t *testing.T) {
ctx, done, err := aetest.NewContext()
if err != nil {
t.Fatal(err)
}
defer done()
it := &memcache.Item{
Key: "some-key",
Value: []byte("some-value"),
}
err = memcache.Set(ctx, it)
if err != nil {
t.Fatalf("Set err: %v", err)
}
it, err = memcache.Get(ctx, "some-key")
if err != nil {
t.Fatalf("Get err: %v; want no error", err)
}
if g, w := string(it.Value), "some-value"; g != w {
t.Errorf("retrieved Item.Value = %q, want %q", g, w)
}
}
测试Go应用!
>goapp test
2017/01/25 14:19:20 appengine: not running under devappserver2; using some default configuration
INFO 2017-01-25 14:19:23,394 devappserver2.py:756] Skipping SDK update check.
WARNING 2017-01-25 14:19:23,394 devappserver2.py:772] DEFAULT_VERSION_HOSTNAME will not be set correctly with --port=0
Traceback (most recent call last):
File "C:\go_appengine\\dev_appserver.py", line 94, in <module>
_run_file(__file__, globals())
File "C:\go_appengine\\dev_appserver.py", line 90, in _run_file
execfile(_PATHS.script_file(script_name), globals_)
File "C:\go_appengine\google\appengine\tools\devappserver2\devappserver2.py", line 1027, in <module>
main()
File "C:\go_appengine\google\appengine\tools\devappserver2\devappserver2.py", line 1015, in main
dev_server.start(options)
File "C:\go_appengine\google\appengine\tools\devappserver2\devappserver2.py", line 807, in start
request_data, storage_path, options, configuration)
File "C:\go_appengine\google\appengine\tools\devappserver2\devappserver2.py", line 907, in _create_api_server
appidentity_oauth_url=options.appidentity_oauth_url)
File "C:\go_appengine\google\appengine\tools\devappserver2\api_server.py", line 421, in setup_stubs
auto_id_policy=datastore_auto_id_policy)
File "C:\go_appengine\google\appengine\datastore\datastore_sqlite_stub.py", line 615, in __init__
factory=sql_conn)
sqlite3.OperationalError: unable to open database file
--- FAIL: TestFoo (3.20s)
sample_test.go:13: unable to find admin server URL
FAIL
exit status 1
无法进行单体测试的痛苦。 de .)
由于自己的环境出了问题,所以失败了。为了尝试相同的步骤,我在虚拟机上准备了一个清洁的Windows10环境,但遗憾地发现出现了相同的错误,让我感到沮丧。
-
- sqlite3.OperationalError: unable to open database file
- sample_test.go:13: unable to find admin server URL