(t *testing.T)
| 213 | } |
| 214 | |
| 215 | func 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 | |
| 249 | func TestCustomType(t *testing.T) { |
| 250 | c := newFakeContext() |
nothing calls this directly
no test coverage detected
searching dependent graphs…