From 8653944a6daa2f21e2ad73de723dd136e65a420c Mon Sep 17 00:00:00 2001 From: Nick Craig-Wood Date: Sun, 21 Jan 2018 16:56:11 +0000 Subject: [PATCH] Make RangeOption manadatory for Open - #1825 Add an integration test to make sure all backends implement RangeOption correctly. --- .../amazonclouddrive/amazonclouddrive_test.go | 1 + backend/azureblob/azureblob_test.go | 1 + backend/b2/b2_test.go | 1 + backend/box/box_test.go | 1 + backend/cache/cache_test.go | 1 + backend/crypt/crypt2_test.go | 1 + backend/crypt/crypt3_test.go | 1 + backend/crypt/crypt_test.go | 1 + backend/drive/drive_test.go | 1 + backend/dropbox/dropbox_test.go | 1 + backend/ftp/ftp_test.go | 1 + .../googlecloudstorage_test.go | 1 + backend/hubic/hubic_test.go | 1 + backend/local/local_test.go | 1 + backend/onedrive/onedrive_test.go | 1 + backend/pcloud/pcloud_test.go | 1 + backend/qingstor/qingstor_test.go | 1 + backend/s3/s3_test.go | 1 + backend/sftp/sftp_test.go | 1 + backend/swift/swift_test.go | 1 + backend/webdav/webdav_test.go | 1 + backend/yandex/yandex_test.go | 1 + fstest/fstests/fstests.go | 30 ++++++++++++++++--- 23 files changed, 48 insertions(+), 4 deletions(-) diff --git a/backend/amazonclouddrive/amazonclouddrive_test.go b/backend/amazonclouddrive/amazonclouddrive_test.go index 2418119f6..e0450fa03 100644 --- a/backend/amazonclouddrive/amazonclouddrive_test.go +++ b/backend/amazonclouddrive/amazonclouddrive_test.go @@ -62,6 +62,7 @@ func TestObjectSetModTime(t *testing.T) { fstests.TestObjectSetModTime(t) } func TestObjectSize(t *testing.T) { fstests.TestObjectSize(t) } func TestObjectOpen(t *testing.T) { fstests.TestObjectOpen(t) } func TestObjectOpenSeek(t *testing.T) { fstests.TestObjectOpenSeek(t) } +func TestObjectOpenRange(t *testing.T) { fstests.TestObjectOpenRange(t) } func TestObjectPartialRead(t *testing.T) { fstests.TestObjectPartialRead(t) } func TestObjectUpdate(t *testing.T) { fstests.TestObjectUpdate(t) } func TestObjectStorable(t *testing.T) { fstests.TestObjectStorable(t) } diff --git a/backend/azureblob/azureblob_test.go b/backend/azureblob/azureblob_test.go index 48f9c11aa..3de0609dd 100644 --- a/backend/azureblob/azureblob_test.go +++ b/backend/azureblob/azureblob_test.go @@ -65,6 +65,7 @@ func TestObjectSetModTime(t *testing.T) { fstests.TestObjectSetModTime(t) } func TestObjectSize(t *testing.T) { fstests.TestObjectSize(t) } func TestObjectOpen(t *testing.T) { fstests.TestObjectOpen(t) } func TestObjectOpenSeek(t *testing.T) { fstests.TestObjectOpenSeek(t) } +func TestObjectOpenRange(t *testing.T) { fstests.TestObjectOpenRange(t) } func TestObjectPartialRead(t *testing.T) { fstests.TestObjectPartialRead(t) } func TestObjectUpdate(t *testing.T) { fstests.TestObjectUpdate(t) } func TestObjectStorable(t *testing.T) { fstests.TestObjectStorable(t) } diff --git a/backend/b2/b2_test.go b/backend/b2/b2_test.go index 124559c61..2ecc31f2c 100644 --- a/backend/b2/b2_test.go +++ b/backend/b2/b2_test.go @@ -62,6 +62,7 @@ func TestObjectSetModTime(t *testing.T) { fstests.TestObjectSetModTime(t) } func TestObjectSize(t *testing.T) { fstests.TestObjectSize(t) } func TestObjectOpen(t *testing.T) { fstests.TestObjectOpen(t) } func TestObjectOpenSeek(t *testing.T) { fstests.TestObjectOpenSeek(t) } +func TestObjectOpenRange(t *testing.T) { fstests.TestObjectOpenRange(t) } func TestObjectPartialRead(t *testing.T) { fstests.TestObjectPartialRead(t) } func TestObjectUpdate(t *testing.T) { fstests.TestObjectUpdate(t) } func TestObjectStorable(t *testing.T) { fstests.TestObjectStorable(t) } diff --git a/backend/box/box_test.go b/backend/box/box_test.go index dc3bfd549..9d0a84526 100644 --- a/backend/box/box_test.go +++ b/backend/box/box_test.go @@ -62,6 +62,7 @@ func TestObjectSetModTime(t *testing.T) { fstests.TestObjectSetModTime(t) } func TestObjectSize(t *testing.T) { fstests.TestObjectSize(t) } func TestObjectOpen(t *testing.T) { fstests.TestObjectOpen(t) } func TestObjectOpenSeek(t *testing.T) { fstests.TestObjectOpenSeek(t) } +func TestObjectOpenRange(t *testing.T) { fstests.TestObjectOpenRange(t) } func TestObjectPartialRead(t *testing.T) { fstests.TestObjectPartialRead(t) } func TestObjectUpdate(t *testing.T) { fstests.TestObjectUpdate(t) } func TestObjectStorable(t *testing.T) { fstests.TestObjectStorable(t) } diff --git a/backend/cache/cache_test.go b/backend/cache/cache_test.go index 7da438fc0..0a118c25e 100644 --- a/backend/cache/cache_test.go +++ b/backend/cache/cache_test.go @@ -66,6 +66,7 @@ func TestObjectSetModTime(t *testing.T) { fstests.TestObjectSetModTime(t) } func TestObjectSize(t *testing.T) { fstests.TestObjectSize(t) } func TestObjectOpen(t *testing.T) { fstests.TestObjectOpen(t) } func TestObjectOpenSeek(t *testing.T) { fstests.TestObjectOpenSeek(t) } +func TestObjectOpenRange(t *testing.T) { fstests.TestObjectOpenRange(t) } func TestObjectPartialRead(t *testing.T) { fstests.TestObjectPartialRead(t) } func TestObjectUpdate(t *testing.T) { fstests.TestObjectUpdate(t) } func TestObjectStorable(t *testing.T) { fstests.TestObjectStorable(t) } diff --git a/backend/crypt/crypt2_test.go b/backend/crypt/crypt2_test.go index 5b83fae52..715090ed2 100644 --- a/backend/crypt/crypt2_test.go +++ b/backend/crypt/crypt2_test.go @@ -63,6 +63,7 @@ func TestObjectSetModTime2(t *testing.T) { fstests.TestObjectSetModTime(t) } func TestObjectSize2(t *testing.T) { fstests.TestObjectSize(t) } func TestObjectOpen2(t *testing.T) { fstests.TestObjectOpen(t) } func TestObjectOpenSeek2(t *testing.T) { fstests.TestObjectOpenSeek(t) } +func TestObjectOpenRange2(t *testing.T) { fstests.TestObjectOpenRange(t) } func TestObjectPartialRead2(t *testing.T) { fstests.TestObjectPartialRead(t) } func TestObjectUpdate2(t *testing.T) { fstests.TestObjectUpdate(t) } func TestObjectStorable2(t *testing.T) { fstests.TestObjectStorable(t) } diff --git a/backend/crypt/crypt3_test.go b/backend/crypt/crypt3_test.go index db253515f..2737a39c2 100644 --- a/backend/crypt/crypt3_test.go +++ b/backend/crypt/crypt3_test.go @@ -63,6 +63,7 @@ func TestObjectSetModTime3(t *testing.T) { fstests.TestObjectSetModTime(t) } func TestObjectSize3(t *testing.T) { fstests.TestObjectSize(t) } func TestObjectOpen3(t *testing.T) { fstests.TestObjectOpen(t) } func TestObjectOpenSeek3(t *testing.T) { fstests.TestObjectOpenSeek(t) } +func TestObjectOpenRange3(t *testing.T) { fstests.TestObjectOpenRange(t) } func TestObjectPartialRead3(t *testing.T) { fstests.TestObjectPartialRead(t) } func TestObjectUpdate3(t *testing.T) { fstests.TestObjectUpdate(t) } func TestObjectStorable3(t *testing.T) { fstests.TestObjectStorable(t) } diff --git a/backend/crypt/crypt_test.go b/backend/crypt/crypt_test.go index 1f51b1556..030586dbf 100644 --- a/backend/crypt/crypt_test.go +++ b/backend/crypt/crypt_test.go @@ -63,6 +63,7 @@ func TestObjectSetModTime(t *testing.T) { fstests.TestObjectSetModTime(t) } func TestObjectSize(t *testing.T) { fstests.TestObjectSize(t) } func TestObjectOpen(t *testing.T) { fstests.TestObjectOpen(t) } func TestObjectOpenSeek(t *testing.T) { fstests.TestObjectOpenSeek(t) } +func TestObjectOpenRange(t *testing.T) { fstests.TestObjectOpenRange(t) } func TestObjectPartialRead(t *testing.T) { fstests.TestObjectPartialRead(t) } func TestObjectUpdate(t *testing.T) { fstests.TestObjectUpdate(t) } func TestObjectStorable(t *testing.T) { fstests.TestObjectStorable(t) } diff --git a/backend/drive/drive_test.go b/backend/drive/drive_test.go index 51ff87d60..90f4e9367 100644 --- a/backend/drive/drive_test.go +++ b/backend/drive/drive_test.go @@ -62,6 +62,7 @@ func TestObjectSetModTime(t *testing.T) { fstests.TestObjectSetModTime(t) } func TestObjectSize(t *testing.T) { fstests.TestObjectSize(t) } func TestObjectOpen(t *testing.T) { fstests.TestObjectOpen(t) } func TestObjectOpenSeek(t *testing.T) { fstests.TestObjectOpenSeek(t) } +func TestObjectOpenRange(t *testing.T) { fstests.TestObjectOpenRange(t) } func TestObjectPartialRead(t *testing.T) { fstests.TestObjectPartialRead(t) } func TestObjectUpdate(t *testing.T) { fstests.TestObjectUpdate(t) } func TestObjectStorable(t *testing.T) { fstests.TestObjectStorable(t) } diff --git a/backend/dropbox/dropbox_test.go b/backend/dropbox/dropbox_test.go index aba1cf563..2ca4b7c06 100644 --- a/backend/dropbox/dropbox_test.go +++ b/backend/dropbox/dropbox_test.go @@ -65,6 +65,7 @@ func TestObjectSetModTime(t *testing.T) { fstests.TestObjectSetModTime(t) } func TestObjectSize(t *testing.T) { fstests.TestObjectSize(t) } func TestObjectOpen(t *testing.T) { fstests.TestObjectOpen(t) } func TestObjectOpenSeek(t *testing.T) { fstests.TestObjectOpenSeek(t) } +func TestObjectOpenRange(t *testing.T) { fstests.TestObjectOpenRange(t) } func TestObjectPartialRead(t *testing.T) { fstests.TestObjectPartialRead(t) } func TestObjectUpdate(t *testing.T) { fstests.TestObjectUpdate(t) } func TestObjectStorable(t *testing.T) { fstests.TestObjectStorable(t) } diff --git a/backend/ftp/ftp_test.go b/backend/ftp/ftp_test.go index 73124f6f1..252eec306 100644 --- a/backend/ftp/ftp_test.go +++ b/backend/ftp/ftp_test.go @@ -62,6 +62,7 @@ func TestObjectSetModTime(t *testing.T) { fstests.TestObjectSetModTime(t) } func TestObjectSize(t *testing.T) { fstests.TestObjectSize(t) } func TestObjectOpen(t *testing.T) { fstests.TestObjectOpen(t) } func TestObjectOpenSeek(t *testing.T) { fstests.TestObjectOpenSeek(t) } +func TestObjectOpenRange(t *testing.T) { fstests.TestObjectOpenRange(t) } func TestObjectPartialRead(t *testing.T) { fstests.TestObjectPartialRead(t) } func TestObjectUpdate(t *testing.T) { fstests.TestObjectUpdate(t) } func TestObjectStorable(t *testing.T) { fstests.TestObjectStorable(t) } diff --git a/backend/googlecloudstorage/googlecloudstorage_test.go b/backend/googlecloudstorage/googlecloudstorage_test.go index 9b8cd9580..e782a93c9 100644 --- a/backend/googlecloudstorage/googlecloudstorage_test.go +++ b/backend/googlecloudstorage/googlecloudstorage_test.go @@ -62,6 +62,7 @@ func TestObjectSetModTime(t *testing.T) { fstests.TestObjectSetModTime(t) } func TestObjectSize(t *testing.T) { fstests.TestObjectSize(t) } func TestObjectOpen(t *testing.T) { fstests.TestObjectOpen(t) } func TestObjectOpenSeek(t *testing.T) { fstests.TestObjectOpenSeek(t) } +func TestObjectOpenRange(t *testing.T) { fstests.TestObjectOpenRange(t) } func TestObjectPartialRead(t *testing.T) { fstests.TestObjectPartialRead(t) } func TestObjectUpdate(t *testing.T) { fstests.TestObjectUpdate(t) } func TestObjectStorable(t *testing.T) { fstests.TestObjectStorable(t) } diff --git a/backend/hubic/hubic_test.go b/backend/hubic/hubic_test.go index 719e48733..d8a9dfd54 100644 --- a/backend/hubic/hubic_test.go +++ b/backend/hubic/hubic_test.go @@ -62,6 +62,7 @@ func TestObjectSetModTime(t *testing.T) { fstests.TestObjectSetModTime(t) } func TestObjectSize(t *testing.T) { fstests.TestObjectSize(t) } func TestObjectOpen(t *testing.T) { fstests.TestObjectOpen(t) } func TestObjectOpenSeek(t *testing.T) { fstests.TestObjectOpenSeek(t) } +func TestObjectOpenRange(t *testing.T) { fstests.TestObjectOpenRange(t) } func TestObjectPartialRead(t *testing.T) { fstests.TestObjectPartialRead(t) } func TestObjectUpdate(t *testing.T) { fstests.TestObjectUpdate(t) } func TestObjectStorable(t *testing.T) { fstests.TestObjectStorable(t) } diff --git a/backend/local/local_test.go b/backend/local/local_test.go index 204ccec01..31c76e775 100644 --- a/backend/local/local_test.go +++ b/backend/local/local_test.go @@ -62,6 +62,7 @@ func TestObjectSetModTime(t *testing.T) { fstests.TestObjectSetModTime(t) } func TestObjectSize(t *testing.T) { fstests.TestObjectSize(t) } func TestObjectOpen(t *testing.T) { fstests.TestObjectOpen(t) } func TestObjectOpenSeek(t *testing.T) { fstests.TestObjectOpenSeek(t) } +func TestObjectOpenRange(t *testing.T) { fstests.TestObjectOpenRange(t) } func TestObjectPartialRead(t *testing.T) { fstests.TestObjectPartialRead(t) } func TestObjectUpdate(t *testing.T) { fstests.TestObjectUpdate(t) } func TestObjectStorable(t *testing.T) { fstests.TestObjectStorable(t) } diff --git a/backend/onedrive/onedrive_test.go b/backend/onedrive/onedrive_test.go index 67ea534e5..23af86c69 100644 --- a/backend/onedrive/onedrive_test.go +++ b/backend/onedrive/onedrive_test.go @@ -62,6 +62,7 @@ func TestObjectSetModTime(t *testing.T) { fstests.TestObjectSetModTime(t) } func TestObjectSize(t *testing.T) { fstests.TestObjectSize(t) } func TestObjectOpen(t *testing.T) { fstests.TestObjectOpen(t) } func TestObjectOpenSeek(t *testing.T) { fstests.TestObjectOpenSeek(t) } +func TestObjectOpenRange(t *testing.T) { fstests.TestObjectOpenRange(t) } func TestObjectPartialRead(t *testing.T) { fstests.TestObjectPartialRead(t) } func TestObjectUpdate(t *testing.T) { fstests.TestObjectUpdate(t) } func TestObjectStorable(t *testing.T) { fstests.TestObjectStorable(t) } diff --git a/backend/pcloud/pcloud_test.go b/backend/pcloud/pcloud_test.go index b0a4b9a89..53d7c49ff 100644 --- a/backend/pcloud/pcloud_test.go +++ b/backend/pcloud/pcloud_test.go @@ -62,6 +62,7 @@ func TestObjectSetModTime(t *testing.T) { fstests.TestObjectSetModTime(t) } func TestObjectSize(t *testing.T) { fstests.TestObjectSize(t) } func TestObjectOpen(t *testing.T) { fstests.TestObjectOpen(t) } func TestObjectOpenSeek(t *testing.T) { fstests.TestObjectOpenSeek(t) } +func TestObjectOpenRange(t *testing.T) { fstests.TestObjectOpenRange(t) } func TestObjectPartialRead(t *testing.T) { fstests.TestObjectPartialRead(t) } func TestObjectUpdate(t *testing.T) { fstests.TestObjectUpdate(t) } func TestObjectStorable(t *testing.T) { fstests.TestObjectStorable(t) } diff --git a/backend/qingstor/qingstor_test.go b/backend/qingstor/qingstor_test.go index f08e4c815..eeb359273 100644 --- a/backend/qingstor/qingstor_test.go +++ b/backend/qingstor/qingstor_test.go @@ -65,6 +65,7 @@ func TestObjectSetModTime(t *testing.T) { fstests.TestObjectSetModTime(t) } func TestObjectSize(t *testing.T) { fstests.TestObjectSize(t) } func TestObjectOpen(t *testing.T) { fstests.TestObjectOpen(t) } func TestObjectOpenSeek(t *testing.T) { fstests.TestObjectOpenSeek(t) } +func TestObjectOpenRange(t *testing.T) { fstests.TestObjectOpenRange(t) } func TestObjectPartialRead(t *testing.T) { fstests.TestObjectPartialRead(t) } func TestObjectUpdate(t *testing.T) { fstests.TestObjectUpdate(t) } func TestObjectStorable(t *testing.T) { fstests.TestObjectStorable(t) } diff --git a/backend/s3/s3_test.go b/backend/s3/s3_test.go index 3328206f4..cd988b36c 100644 --- a/backend/s3/s3_test.go +++ b/backend/s3/s3_test.go @@ -62,6 +62,7 @@ func TestObjectSetModTime(t *testing.T) { fstests.TestObjectSetModTime(t) } func TestObjectSize(t *testing.T) { fstests.TestObjectSize(t) } func TestObjectOpen(t *testing.T) { fstests.TestObjectOpen(t) } func TestObjectOpenSeek(t *testing.T) { fstests.TestObjectOpenSeek(t) } +func TestObjectOpenRange(t *testing.T) { fstests.TestObjectOpenRange(t) } func TestObjectPartialRead(t *testing.T) { fstests.TestObjectPartialRead(t) } func TestObjectUpdate(t *testing.T) { fstests.TestObjectUpdate(t) } func TestObjectStorable(t *testing.T) { fstests.TestObjectStorable(t) } diff --git a/backend/sftp/sftp_test.go b/backend/sftp/sftp_test.go index fa7d8b2bd..c5f9439bb 100644 --- a/backend/sftp/sftp_test.go +++ b/backend/sftp/sftp_test.go @@ -62,6 +62,7 @@ func TestObjectSetModTime(t *testing.T) { fstests.TestObjectSetModTime(t) } func TestObjectSize(t *testing.T) { fstests.TestObjectSize(t) } func TestObjectOpen(t *testing.T) { fstests.TestObjectOpen(t) } func TestObjectOpenSeek(t *testing.T) { fstests.TestObjectOpenSeek(t) } +func TestObjectOpenRange(t *testing.T) { fstests.TestObjectOpenRange(t) } func TestObjectPartialRead(t *testing.T) { fstests.TestObjectPartialRead(t) } func TestObjectUpdate(t *testing.T) { fstests.TestObjectUpdate(t) } func TestObjectStorable(t *testing.T) { fstests.TestObjectStorable(t) } diff --git a/backend/swift/swift_test.go b/backend/swift/swift_test.go index dce9d4072..e68b24613 100644 --- a/backend/swift/swift_test.go +++ b/backend/swift/swift_test.go @@ -62,6 +62,7 @@ func TestObjectSetModTime(t *testing.T) { fstests.TestObjectSetModTime(t) } func TestObjectSize(t *testing.T) { fstests.TestObjectSize(t) } func TestObjectOpen(t *testing.T) { fstests.TestObjectOpen(t) } func TestObjectOpenSeek(t *testing.T) { fstests.TestObjectOpenSeek(t) } +func TestObjectOpenRange(t *testing.T) { fstests.TestObjectOpenRange(t) } func TestObjectPartialRead(t *testing.T) { fstests.TestObjectPartialRead(t) } func TestObjectUpdate(t *testing.T) { fstests.TestObjectUpdate(t) } func TestObjectStorable(t *testing.T) { fstests.TestObjectStorable(t) } diff --git a/backend/webdav/webdav_test.go b/backend/webdav/webdav_test.go index beb3193f0..bc880993c 100644 --- a/backend/webdav/webdav_test.go +++ b/backend/webdav/webdav_test.go @@ -62,6 +62,7 @@ func TestObjectSetModTime(t *testing.T) { fstests.TestObjectSetModTime(t) } func TestObjectSize(t *testing.T) { fstests.TestObjectSize(t) } func TestObjectOpen(t *testing.T) { fstests.TestObjectOpen(t) } func TestObjectOpenSeek(t *testing.T) { fstests.TestObjectOpenSeek(t) } +func TestObjectOpenRange(t *testing.T) { fstests.TestObjectOpenRange(t) } func TestObjectPartialRead(t *testing.T) { fstests.TestObjectPartialRead(t) } func TestObjectUpdate(t *testing.T) { fstests.TestObjectUpdate(t) } func TestObjectStorable(t *testing.T) { fstests.TestObjectStorable(t) } diff --git a/backend/yandex/yandex_test.go b/backend/yandex/yandex_test.go index 5bc62ec7a..65743036d 100644 --- a/backend/yandex/yandex_test.go +++ b/backend/yandex/yandex_test.go @@ -62,6 +62,7 @@ func TestObjectSetModTime(t *testing.T) { fstests.TestObjectSetModTime(t) } func TestObjectSize(t *testing.T) { fstests.TestObjectSize(t) } func TestObjectOpen(t *testing.T) { fstests.TestObjectOpen(t) } func TestObjectOpenSeek(t *testing.T) { fstests.TestObjectOpenSeek(t) } +func TestObjectOpenRange(t *testing.T) { fstests.TestObjectOpenRange(t) } func TestObjectPartialRead(t *testing.T) { fstests.TestObjectPartialRead(t) } func TestObjectUpdate(t *testing.T) { fstests.TestObjectUpdate(t) } func TestObjectStorable(t *testing.T) { fstests.TestObjectStorable(t) } diff --git a/fstest/fstests/fstests.go b/fstest/fstests/fstests.go index 92206f82d..cf2550fce 100644 --- a/fstest/fstests/fstests.go +++ b/fstest/fstests/fstests.go @@ -792,16 +792,17 @@ func TestObjectSize(t *testing.T) { // read the contents of an object as a string func readObject(t *testing.T, obj fs.Object, limit int64, options ...fs.OpenOption) string { + what := fmt.Sprintf("readObject(%q) limit=%d, options=%+v", obj, limit, options) in, err := obj.Open(options...) - require.NoError(t, err) + require.NoError(t, err, what) var r io.Reader = in if limit >= 0 { r = &io.LimitedReader{R: r, N: limit} } contents, err := ioutil.ReadAll(r) - require.NoError(t, err) + require.NoError(t, err, what) err = in.Close() - require.NoError(t, err) + require.NoError(t, err, what) return string(contents) } @@ -812,13 +813,34 @@ func TestObjectOpen(t *testing.T) { assert.Equal(t, file1Contents, readObject(t, obj, -1), "contents of file1 differ") } -// TestObjectOpenSeek tests that Open works with Seek +// TestObjectOpenSeek tests that Open works with SeekOption func TestObjectOpenSeek(t *testing.T) { skipIfNotOk(t) obj := findObject(t, file1.Path) assert.Equal(t, file1Contents[50:], readObject(t, obj, -1, &fs.SeekOption{Offset: 50}), "contents of file1 differ after seek") } +// TestObjectOpenRange tests that Open works with RangeOption +func TestObjectOpenRange(t *testing.T) { + skipIfNotOk(t) + obj := findObject(t, file1.Path) + for _, test := range []struct { + ro fs.RangeOption + wantStart, wantEnd int + }{ + {fs.RangeOption{Start: 5, End: 15}, 5, 16}, + {fs.RangeOption{Start: 80, End: -1}, 80, 100}, + {fs.RangeOption{Start: 81, End: 100000}, 81, 100}, + {fs.RangeOption{Start: -1, End: 20}, 80, 100}, // if start is omitted this means get the final bytes + // {fs.RangeOption{Start: -1, End: -1}, 0, 100}, - this seems to work but the RFC doesn't define it + } { + got := readObject(t, obj, -1, &test.ro) + foundAt := strings.Index(file1Contents, got) + help := fmt.Sprintf("%#v failed want [%d:%d] got [%d:%d]", test.ro, test.wantStart, test.wantEnd, foundAt, foundAt+len(got)) + assert.Equal(t, file1Contents[test.wantStart:test.wantEnd], got, help) + } +} + // TestObjectPartialRead tests that reading only part of the object does the correct thing func TestObjectPartialRead(t *testing.T) { skipIfNotOk(t)