| 234 | } |
| 235 | |
| 236 | void GenericFileSystemTest::TestCreateDir(FileSystem* fs) { |
| 237 | ASSERT_OK(fs->CreateDir("AB")); |
| 238 | ASSERT_OK(fs->CreateDir("AB/CD/EF")); // Recursive |
| 239 | if (!have_implicit_directories()) { |
| 240 | // Non-recursive, parent doesn't exist |
| 241 | ASSERT_RAISES(IOError, fs->CreateDir("AB/GH/IJ", false /* recursive */)); |
| 242 | } |
| 243 | ASSERT_OK(fs->CreateDir("AB/GH", false /* recursive */)); |
| 244 | ASSERT_OK(fs->CreateDir("AB/GH/IJ", false /* recursive */)); |
| 245 | // Idempotency |
| 246 | ASSERT_OK(fs->CreateDir("AB/GH/IJ", false /* recursive */)); |
| 247 | ASSERT_OK(fs->CreateDir("XY")); |
| 248 | |
| 249 | AssertAllDirs(fs, {"AB", "AB/CD", "AB/CD/EF", "AB/GH", "AB/GH/IJ", "XY"}); |
| 250 | AssertAllFiles(fs, {}); |
| 251 | |
| 252 | // Cannot create a directory as child of a file |
| 253 | CreateFile(fs, "AB/def", ""); |
| 254 | ASSERT_RAISES(IOError, fs->CreateDir("AB/def/EF/GH", true /* recursive */)); |
| 255 | ASSERT_RAISES(IOError, fs->CreateDir("AB/def/EF", false /* recursive */)); |
| 256 | |
| 257 | // Cannot create a directory when there is already a file with the same name |
| 258 | ASSERT_RAISES(IOError, fs->CreateDir("AB/def")); |
| 259 | |
| 260 | AssertAllDirs(fs, {"AB", "AB/CD", "AB/CD/EF", "AB/GH", "AB/GH/IJ", "XY"}); |
| 261 | AssertAllFiles(fs, {"AB/def"}); |
| 262 | } |
| 263 | |
| 264 | void GenericFileSystemTest::TestDeleteDir(FileSystem* fs) { |
| 265 | if (have_flaky_directory_tree_deletion()) GTEST_SKIP() << "Flaky directory deletion"; |
nothing calls this directly
no test coverage detected