1
0
mirror of https://github.com/rclone/rclone.git synced 2025-12-20 18:23:31 +00:00

vendor: update all dependencies

This commit is contained in:
Nick Craig-Wood
2018-06-17 17:59:12 +01:00
parent 3f0789e2db
commit 08021c4636
2474 changed files with 435818 additions and 282709 deletions

View File

@@ -94,6 +94,14 @@ var (
dupeWhich = 2
}
})
reqFuncRuns = 0
reqFuncHeaders *taskqueue.RequestHeaders
reqFuncErr error
reqFunc = Func("req", func(c context.Context) {
reqFuncRuns++
reqFuncHeaders, reqFuncErr = RequestHeaders(c)
})
)
type fakeContext struct {
@@ -373,3 +381,48 @@ func TestDuplicateFunction(t *testing.T) {
t.Errorf("dupeWhich = %d; want 2", dupeWhich)
}
}
func TestGetRequestHeadersFromContext(t *testing.T) {
c := newFakeContext()
// Outside a delay.Func should return an error.
headers, err := RequestHeaders(c.ctx)
if headers != nil {
t.Errorf("RequestHeaders outside Func, got %v, want nil", headers)
}
if err != errOutsideDelayFunc {
t.Errorf("RequestHeaders outside Func err, got %v, want %v", err, errOutsideDelayFunc)
}
// Fake out the adding of a task.
var task *taskqueue.Task
taskqueueAdder = func(_ context.Context, tk *taskqueue.Task, queue string) (*taskqueue.Task, error) {
if queue != "" {
t.Errorf(`Got queue %q, expected ""`, queue)
}
task = tk
return tk, nil
}
reqFunc.Call(c.ctx)
reqFuncRuns, reqFuncHeaders = 0, nil // reset state
// Simulate the Task Queue service.
req, err := http.NewRequest("POST", path, bytes.NewBuffer(task.Payload))
req.Header.Set("x-appengine-taskname", "foobar")
if err != nil {
t.Fatalf("Failed making http.Request: %v", err)
}
rw := httptest.NewRecorder()
runFunc(c.ctx, rw, req)
if reqFuncRuns != 1 {
t.Errorf("reqFuncRuns: got %d, want 1", reqFuncRuns)
}
if reqFuncHeaders.TaskName != "foobar" {
t.Errorf("reqFuncHeaders.TaskName: got %v, want 'foobar'", reqFuncHeaders.TaskName)
}
if reqFuncErr != nil {
t.Errorf("reqFuncErr: got %v, want nil", reqFuncErr)
}
}