Adding a new test for read with offset

This commit is contained in:
Jakub Kuklis 2021-11-10 10:56:03 +00:00
parent 9a00acfb72
commit c4691affb2
2 changed files with 16 additions and 0 deletions

View File

@ -182,6 +182,7 @@ void DiskBlobStorage::applyNewSettings(const Poco::Util::AbstractConfiguration &
} }
// TODO: remove this function or make it a unit test accessing a public url
void blob_storage_demo() void blob_storage_demo()
{ {
// to not repeat it for every storage function // to not repeat it for every storage function

View File

@ -46,6 +46,20 @@ void checkReadAccess(IDisk & disk)
} }
// TODO: make it a unit test ?
void checkReadWithOffset(IDisk & disk)
{
auto file = disk.readFile(test_file, DBMS_DEFAULT_BUFFER_SIZE);
auto offset = 2;
auto test_size = test_str_size - offset;
String buf(test_size, '0');
file->seek(offset, 0);
file->readStrict(buf.data(), test_size);
if (buf != test_str + offset)
throw Exception("Failed to read file with offset", ErrorCodes::PATH_ACCESS_DENIED);
}
void checkRemoveAccess(IDisk & disk) void checkRemoveAccess(IDisk & disk)
{ {
// TODO: remove these checks if the names of blobs will be changed // TODO: remove these checks if the names of blobs will be changed
@ -115,6 +129,7 @@ void registerDiskBlobStorage(DiskFactory & factory)
{ {
checkWriteAccess(*blob_storage_disk); checkWriteAccess(*blob_storage_disk);
checkReadAccess(*blob_storage_disk); checkReadAccess(*blob_storage_disk);
checkReadWithOffset(*blob_storage_disk);
checkRemoveAccess(*blob_storage_disk); checkRemoveAccess(*blob_storage_disk);
} }