mirror of
https://github.com/rclone/rclone.git
synced 2025-08-24 03:45:45 +02:00
operations: add operations.ReadFile to read the contents of a file into memory
This commit is contained in:
@@ -492,6 +492,23 @@ func TestMaxDeleteSize(t *testing.T) {
|
||||
assert.Equal(t, int64(1), objects) // 10 or 100 bytes
|
||||
}
|
||||
|
||||
func TestReadFile(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
r := fstest.NewRun(t)
|
||||
defer r.Finalise()
|
||||
|
||||
contents := "A file to read the contents."
|
||||
file := r.WriteObject(ctx, "ReadFile", contents, t1)
|
||||
r.CheckRemoteItems(t, file)
|
||||
|
||||
o, err := r.Fremote.NewObject(ctx, file.Path)
|
||||
require.NoError(t, err)
|
||||
|
||||
buf, err := operations.ReadFile(ctx, o)
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, contents, string(buf))
|
||||
}
|
||||
|
||||
func TestRetry(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
|
||||
|
Reference in New Issue
Block a user