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

Function TestRunningFunction

delay/delay_test.go:197–228  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

195}
196
197func TestRunningFunction(t *testing.T) {
198 c := newFakeContext()
199
200 // Fake out the adding of a task.
201 var task *taskqueue.Task
202 taskqueueAdder = func(_ context.Context, tk *taskqueue.Task, queue string) (*taskqueue.Task, error) {
203 if queue != "" {
204 t.Errorf(`Got queue %q, expected ""`, queue)
205 }
206 task = tk
207 return tk, nil
208 }
209
210 regFuncRuns, regFuncMsg = 0, "" // reset state
211 const msg = "Why, hello!"
212 regFunc.Call(c.ctx, msg)
213
214 // Simulate the Task Queue service.
215 req, err := http.NewRequest("POST", path, bytes.NewBuffer(task.Payload))
216 if err != nil {
217 t.Fatalf("Failed making http.Request: %v", err)
218 }
219 rw := httptest.NewRecorder()
220 runFunc(c.ctx, rw, req)
221
222 if regFuncRuns != 1 {
223 t.Errorf("regFuncRuns: got %d, want 1", regFuncRuns)
224 }
225 if regFuncMsg != msg {
226 t.Errorf("regFuncMsg: got %q, want %q", regFuncMsg, msg)
227 }
228}
229
230func TestCustomType(t *testing.T) {
231 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…