MCPcopy Create free account
hub / github.com/golang/appengine / TestRunningFunction

Function TestRunningFunction

v2/delay/delay_test.go:215–247  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

213}
214
215func TestRunningFunction(t *testing.T) {
216 c := newFakeContext()
217 // Fake out the adding of a task.
218 var task *taskqueue.Task
219 taskqueueAdder = func(_ context.Context, tk *taskqueue.Task, queue string) (*taskqueue.Task, error) {
220 if queue != "" {
221 t.Errorf(`Got queue %q, expected ""`, queue)
222 }
223 task = tk
224 return tk, nil
225 }
226
227 for _, testTarget := range []*Function{regFunc, regRegister} {
228 regFRuns, regFMsg = 0, "" // reset state
229 const msg = "Why, hello!"
230 testTarget.Call(c.ctx, msg)
231
232 // Simulate the Task Queue service.
233 req, err := http.NewRequest("POST", path, bytes.NewBuffer(task.Payload))
234 if err != nil {
235 t.Fatalf("Failed making http.Request: %v", err)
236 }
237 rw := httptest.NewRecorder()
238 runFunc(c.ctx, rw, req)
239
240 if regFRuns != 1 {
241 t.Errorf("regFuncRuns: got %d, want 1", regFRuns)
242 }
243 if regFMsg != msg {
244 t.Errorf("regFuncMsg: got %q, want %q", regFMsg, msg)
245 }
246 }
247}
248
249func TestCustomType(t *testing.T) {
250 c := newFakeContext()

Callers

nothing calls this directly

Calls 4

newFakeContextFunction · 0.70
runFuncFunction · 0.70
NewRequestMethod · 0.65
CallMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…