(t *testing.T)
| 19 | ) |
| 20 | |
| 21 | func TestAddErrors(t *testing.T) { |
| 22 | var tests = []struct { |
| 23 | err, want error |
| 24 | sameErr bool // if true, should return err exactly |
| 25 | }{ |
| 26 | { |
| 27 | err: &internal.APIError{ |
| 28 | Service: "taskqueue", |
| 29 | Code: int32(pb.TaskQueueServiceError_TASK_ALREADY_EXISTS), |
| 30 | }, |
| 31 | want: ErrTaskAlreadyAdded, |
| 32 | }, |
| 33 | { |
| 34 | err: &internal.APIError{ |
| 35 | Service: "taskqueue", |
| 36 | Code: int32(pb.TaskQueueServiceError_TOMBSTONED_TASK), |
| 37 | }, |
| 38 | want: ErrTaskAlreadyAdded, |
| 39 | }, |
| 40 | { |
| 41 | err: &internal.APIError{ |
| 42 | Service: "taskqueue", |
| 43 | Code: int32(pb.TaskQueueServiceError_UNKNOWN_QUEUE), |
| 44 | }, |
| 45 | want: errors.New("not used"), |
| 46 | sameErr: true, |
| 47 | }, |
| 48 | } |
| 49 | for _, tc := range tests { |
| 50 | c := aetesting.FakeSingleContext(t, "taskqueue", "Add", func(req *pb.TaskQueueAddRequest, res *pb.TaskQueueAddResponse) error { |
| 51 | // don't fill in any of the response |
| 52 | return tc.err |
| 53 | }) |
| 54 | task := &Task{Path: "/worker", Method: "PULL"} |
| 55 | _, err := Add(c, task, "a-queue") |
| 56 | want := tc.want |
| 57 | if tc.sameErr { |
| 58 | want = tc.err |
| 59 | } |
| 60 | if err != want { |
| 61 | t.Errorf("Add with tc.err = %v, got %#v, want = %#v", tc.err, err, want) |
| 62 | } |
| 63 | } |
| 64 | } |
| 65 | |
| 66 | func TestAddMulti(t *testing.T) { |
| 67 | c := aetesting.FakeSingleContext(t, "taskqueue", "BulkAdd", func(req *pb.TaskQueueBulkAddRequest, res *pb.TaskQueueBulkAddResponse) error { |
nothing calls this directly
no test coverage detected
searching dependent graphs…