MCPcopy Create free account
hub / github.com/apache/arrow / TestDeleteDirContents

Method TestDeleteDirContents

cpp/src/arrow/filesystem/test_util.cc:292–321  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

290}
291
292void GenericFileSystemTest::TestDeleteDirContents(FileSystem* fs) {
293 if (have_flaky_directory_tree_deletion()) GTEST_SKIP() << "Flaky directory deletion";
294
295 ASSERT_OK(fs->CreateDir("AB/CD/EF"));
296 ASSERT_OK(fs->CreateDir("AB/GH/IJ"));
297 CreateFile(fs, "AB/abc", "");
298 CreateFile(fs, "AB/CD/def", "");
299 CreateFile(fs, "AB/CD/EF/ghi", "");
300 ASSERT_OK(fs->DeleteDirContents("AB/CD"));
301 ASSERT_OK(fs->DeleteDirContents("AB/GH/IJ"));
302
303 AssertAllDirs(fs, {"AB", "AB/CD", "AB/GH", "AB/GH/IJ"});
304 AssertAllFiles(fs, {"AB/abc"});
305
306 // Calling DeleteDirContents on root directory is disallowed
307 ASSERT_RAISES(Invalid, fs->DeleteDirContents(""));
308 ASSERT_RAISES(Invalid, fs->DeleteDirContents("/"));
309 AssertAllDirs(fs, {"AB", "AB/CD", "AB/GH", "AB/GH/IJ"});
310 AssertAllFiles(fs, {"AB/abc"});
311
312 // Not a directory
313 CreateFile(fs, "abc", "");
314 ASSERT_RAISES(IOError, fs->DeleteDirContents("abc"));
315 ASSERT_RAISES(IOError, fs->DeleteDirContents("abc", /*missing_dir_ok=*/true));
316 AssertAllFiles(fs, {"AB/abc", "abc"});
317
318 // Missing directory
319 ASSERT_RAISES(IOError, fs->DeleteDirContents("missing"));
320 ASSERT_OK(fs->DeleteDirContents("missing", /*missing_dir_ok=*/true));
321}
322
323void GenericFileSystemTest::TestDeleteRootDirContents(FileSystem* fs) {
324 if (have_flaky_directory_tree_deletion()) GTEST_SKIP() << "Flaky directory deletion";

Callers

nothing calls this directly

Calls 6

CreateFileFunction · 0.85
AssertAllDirsFunction · 0.85
AssertAllFilesFunction · 0.85
CreateDirMethod · 0.45
DeleteDirContentsMethod · 0.45

Tested by

no test coverage detected