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

Function TestAddMulti

v2/taskqueue/taskqueue_test.go:66–106  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

64}
65
66func TestAddMulti(t *testing.T) {
67 c := aetesting.FakeSingleContext(t, "taskqueue", "BulkAdd", func(req *pb.TaskQueueBulkAddRequest, res *pb.TaskQueueBulkAddResponse) error {
68 res.Taskresult = []*pb.TaskQueueBulkAddResponse_TaskResult{
69 {
70 Result: pb.TaskQueueServiceError_OK.Enum(),
71 },
72 {
73 Result: pb.TaskQueueServiceError_TASK_ALREADY_EXISTS.Enum(),
74 },
75 {
76 Result: pb.TaskQueueServiceError_TOMBSTONED_TASK.Enum(),
77 },
78 {
79 Result: pb.TaskQueueServiceError_INTERNAL_ERROR.Enum(),
80 },
81 }
82 return nil
83 })
84 tasks := []*Task{
85 {Path: "/worker", Method: "PULL"},
86 {Path: "/worker", Method: "PULL"},
87 {Path: "/worker", Method: "PULL"},
88 {Path: "/worker", Method: "PULL"},
89 }
90 r, err := AddMulti(c, tasks, "a-queue")
91 if len(r) != len(tasks) {
92 t.Fatalf("AddMulti returned %d tasks, want %d", len(r), len(tasks))
93 }
94 want := appengine.MultiError{
95 nil,
96 ErrTaskAlreadyAdded,
97 ErrTaskAlreadyAdded,
98 &internal.APIError{
99 Service: "taskqueue",
100 Code: int32(pb.TaskQueueServiceError_INTERNAL_ERROR),
101 },
102 }
103 if !reflect.DeepEqual(err, want) {
104 t.Errorf("AddMulti got %v, wanted %v", err, want)
105 }
106}
107
108func TestAddWithEmptyPath(t *testing.T) {
109 c := aetesting.FakeSingleContext(t, "taskqueue", "Add", func(req *pb.TaskQueueAddRequest, res *pb.TaskQueueAddResponse) error {

Callers

nothing calls this directly

Calls 3

FakeSingleContextFunction · 0.92
AddMultiFunction · 0.70
EnumMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…