av8or1 commented on code in PR #39840:
URL: https://github.com/apache/arrow/pull/39840#discussion_r1473158011
##########
cpp/src/arrow/filesystem/azurefs_test.cc:
##########
@@ -1382,6 +1386,32 @@ TEST_F(TestAzuriteFileSystem,
DeleteDirContentsFailureNonexistent) {
this->TestDeleteDirContentsFailureNonexistent();
}
+TEST_F(AzuriteFileSystemTest, DeleteFileSuccessHaveFile) {
+void CreateFile(FileSystem* fs, const std::string& path, const std::string&
data) {
+ const auto file_name = PreexistingData::RandomFileName() +
+ PreexistingData::RandomFileNameExtension();
+ ASSERT_OK(CreateFile(fs_.get(), file_name, "abc"));
+ arrow::fs::AssertFileInfo(fs_.get(), file_name, FileType::File);
+ ASSERT_OK(fs_->DeleteFile(file_name));
+ arrow::fs::AssertFileInfo(fs_.get(), file_name, FileType::NotFound);
+}
+
+TEST_F(AzuriteFileSystemTest, DeleteFileSuccessNonexistent) {
+ const auto file_name = PreexistingData::RandomFileName() +
+ PreexistingData::RandomFileNameExtension();
+ ASSERT_OK(fs_->DeleteFile(file_name));
+ arrow::fs::AssertFileInfo(fs_.get(), file_name, FileType::NotFound);
+}
+
+TEST_F(AzuriteFileSystemTest, DeleteFileSuccessNotAFile) {
+ const auto container_name = RandomContainerName();
+ ASSERT_OK(fs_->CreateDir(container_name));
+ arrow::fs::AssertFileInfo(fs_.get(), container_name, FileType::Directory);
+ ASSERT_RAISES(IOError, fs_->DeleteFile(container_name));
+ ASSERT_OK(fs_->DeleteDir(container_name));
+ arrow::fs::AssertFileInfo(fs_.get(), container_name, FileType::NotFound);
Review Comment:
The point to this test was to attempt to delete a target that was not a
file. So I created a directory (container), then attempted to delete it, which
should fail, which I verify via:
` ASSERT_RAISES(IOError, fs_->DeleteFile(container_name));`
At line 1410. Then I clean up the mess by deleting the directory
(container) via lines 1411 and 1412 (which is just a verification that the
directory (container) was deleted).
If there is a different approach to this type of test that would be
preferred, let me know.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]