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

Function TestErrorFunction

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

Source from the content-addressed store, hash-verified

304}
305
306func TestErrorFunction(t *testing.T) {
307 c := newFakeContext()
308
309 // Fake out the adding of a task.
310 var task *taskqueue.Task
311 taskqueueAdder = func(_ context.Context, tk *taskqueue.Task, queue string) (*taskqueue.Task, error) {
312 if queue != "" {
313 t.Errorf(`Got queue %q, expected ""`, queue)
314 }
315 task = tk
316 return tk, nil
317 }
318
319 errFunc.Call(c.ctx)
320
321 // Simulate the Task Queue service.
322 // The first call should succeed; the second call should fail.
323 {
324 req, err := http.NewRequest("POST", path, bytes.NewBuffer(task.Payload))
325 if err != nil {
326 t.Fatalf("Failed making http.Request: %v", err)
327 }
328 rw := httptest.NewRecorder()
329 runFunc(c.ctx, rw, req)
330 }
331 {
332 req, err := http.NewRequest("POST", path, bytes.NewBuffer(task.Payload))
333 if err != nil {
334 t.Fatalf("Failed making http.Request: %v", err)
335 }
336 rw := httptest.NewRecorder()
337 runFunc(c.ctx, rw, req)
338 if rw.Code != http.StatusInternalServerError {
339 t.Errorf("Got status code %d, want %d", rw.Code, http.StatusInternalServerError)
340 }
341
342 wantLogging := [][]interface{}{
343 {"ERROR", "delay: func failed (will retry): %v", errFuncErr},
344 }
345 if !reflect.DeepEqual(c.logging, wantLogging) {
346 t.Errorf("Incorrect logging: got %+v, want %+v", c.logging, wantLogging)
347 }
348 }
349}
350
351func TestDuplicateFunction(t *testing.T) {
352 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…