Say I have some test functions like the following:
func TestMyFunction1(t *testing.T) {
inst, err := aetest.NewInstance(&aetest.Options{StronglyConsistentDatastore: true})
if err != nil {
t.Fatalf("Failed to create instance: %v", err)
}
defer inst.Close()
req1, err := inst.NewRequest("GET", "http://localhost:8080/api/some-resource", nil)
if err != nil {
t.Fatalf("Failed to create req1: %v", err)
}
c1 := appengine.NewContext(req1)
resp1, err := appClient.Do(req1)
if err != nil {
t.Fatalf("Failed to create resp1: %v", err)
}
t.Log(resp1)
// Run code and tests with *http.Request req1
// and context.Context c1.
// ...
}
When I run tests like these with goapp test
, it appears that an aetest
instance is created on a unique, random port when each test is invoked:
INFO 2018-01-29 20:56:27,504 api_server.py:205] Starting API server at: http://localhost:37243
INFO 2018-01-29 20:56:27,510 dispatcher.py:197] Starting module "default" running at: http://localhost:42184
INFO 2018-01-29 20:56:27,510 admin_server.py:116] Starting admin server at: http://localhost:43292
--- FAIL: TestMyFunction1 (2.00s)
INFO 2018-01-29 21:06:58,717 api_server.py:205] Starting API server at: http://localhost:43010
INFO 2018-01-29 21:06:58,718 dispatcher.py:197] Starting module "default" running at: http://localhost:37508
INFO 2018-01-29 21:06:58,719 admin_server.py:116] Starting admin server at: http://localhost:45493
--- FAIL: TestMyFunction2 (1.99s)
Is there a way to force an aetest
instance to run on a particular port? Alternatively, is there a way to predetermine the port? It seems that goapp test
wraps dev_appserver.py
(which is where one would normally specify the port), and I can't specify a port when running goapp test
. There is also no port property on the aetest Options
struct.
Aucun commentaire:
Enregistrer un commentaire