| 182 | }; |
| 183 | |
| 184 | TEST(RetryingFileSystemTest, NewRandomAccessFile_ImmediateSuccess) { |
| 185 | // Configure the mock base random access file. |
| 186 | ExpectedCalls expected_file_calls({std::make_tuple("Name", Status::OK()), |
| 187 | std::make_tuple("Read", Status::OK())}); |
| 188 | std::unique_ptr<RandomAccessFile> base_file( |
| 189 | new MockRandomAccessFile(expected_file_calls)); |
| 190 | |
| 191 | // Configure the mock base file system. |
| 192 | ExpectedCalls expected_fs_calls( |
| 193 | {std::make_tuple("NewRandomAccessFile", Status::OK())}); |
| 194 | std::unique_ptr<MockFileSystem> base_fs( |
| 195 | new MockFileSystem(expected_fs_calls)); |
| 196 | base_fs->random_access_file_to_return = std::move(base_file); |
| 197 | RetryingFileSystem<MockFileSystem> fs( |
| 198 | std::move(base_fs), RetryConfig(0 /* init_delay_time_us */)); |
| 199 | |
| 200 | // Retrieve the wrapped random access file. |
| 201 | std::unique_ptr<RandomAccessFile> random_access_file; |
| 202 | TF_EXPECT_OK(fs.NewRandomAccessFile("filename.txt", &random_access_file)); |
| 203 | |
| 204 | // Use it and check the results. |
| 205 | StringPiece result; |
| 206 | TF_EXPECT_OK(random_access_file->Name(&result)); |
| 207 | EXPECT_EQ(result, ""); |
| 208 | |
| 209 | char scratch[10]; |
| 210 | TF_EXPECT_OK(random_access_file->Read(0, 10, &result, scratch)); |
| 211 | } |
| 212 | |
| 213 | TEST(RetryingFileSystemTest, NewRandomAccessFile_SuccessWith3rdTry) { |
| 214 | // Configure the mock base random access file. |
nothing calls this directly
no test coverage detected