operations: add operations.ReadFile to read the contents of a file into memory

This commit is contained in:
Nick Craig-Wood
2023-09-02 18:14:17 +01:00
parent 021f25a748
commit 282e34f2d5
2 changed files with 36 additions and 0 deletions

View File

@@ -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()