Mock function object of fetchData Precise control return value and content of data buffer.
| 227 | // Mock function object of fetchData |
| 228 | // Precise control return value and content of data buffer. |
| 229 | class MockFetchData { |
| 230 | public: |
| 231 | MockFetchData(uint64_t returnLen, uint64_t chunkSize) |
| 232 | : retnLen(returnLen), chunkData(chunkSize) { |
| 233 | } |
| 234 | |
| 235 | MockFetchData(const MockFetchData &other) { |
| 236 | retnLen = other.retnLen; |
| 237 | chunkData = other.chunkData; |
| 238 | } |
| 239 | |
| 240 | uint64_t operator()(uint64_t offset, S3VectorUInt8 &data, uint64_t len, |
| 241 | const S3Url &sourceUrl) { |
| 242 | data = std::move(chunkData); |
| 243 | return retnLen; |
| 244 | } |
| 245 | |
| 246 | private: |
| 247 | uint64_t retnLen; |
| 248 | S3VectorUInt8 chunkData; |
| 249 | }; |
| 250 | |
| 251 | TEST_F(S3KeyReaderTest, ReadWithSingleChunk) { |
| 252 | S3Params params("s3://abc/def"); |