(t *testing.T)
| 304 | } |
| 305 | |
| 306 | func 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 | |
| 351 | func TestDuplicateFunction(t *testing.T) { |
| 352 | c := newFakeContext() |
nothing calls this directly
no test coverage detected
searching dependent graphs…