func Test_AsyncAPI_Define_RecursiveCall(t *testing.T) { assert := gaetest.NewAssert(t) app := NewApp("testapp") async := app.AsyncAPI() var processed = 0 var q1 string config := async.Define("/async/") config.OnProcess(AsyncTaskHandler(func(req *wcg.Request, t *models.AsyncAPITask) (*models.AsyncAPITaskProgress, error) { var progress models.AsyncAPITaskProgress lastp := t.LastProgress() if lastp != nil { progress.Current = lastp.Current + 1 } else { progress.Current++ } progress.Total = 4 // confirm progress text is updated. processed++ if processed == 4 { q1 = req.Query("q1") // no progress returns to stop the task return &progress, nil } if processed == 3 { progress.Next = url.Values{ "q1": []string{"b"}, } } else { progress.Next = url.Values{} } return &progress, nil })) assert.EqStr("api-testapp-async", config.Queue.Name) var path = "/api/testapp/async/" var params = url.Values{} runner := testhelper.NewAsyncTaskTestRunner(t, app.Routes(), ts) task := runner.Run(fmt.Sprintf("%s", path), params) assert.OK(models.AsyncAPIStatusSuccess == task.Status) assert.EqInt(4, len(task.Progress)) assert.EqInt(4, task.LastProgress().Current) assert.EqInt(4, processed) assert.EqStr("b", q1) }