Skip to content

Commit

Permalink
fix clang
Browse files Browse the repository at this point in the history
  • Loading branch information
SterlingT3485 committed Nov 21, 2024
1 parent 50b7e91 commit 7955894
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
1 change: 0 additions & 1 deletion src/main/database.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

#include "main/client_context.h"
#include "main/database_manager.h"
#include "main/settings.h"
#include "storage/buffer_manager/buffer_manager.h"

#if defined(_WIN32)
Expand Down
30 changes: 30 additions & 0 deletions test/c_api/database_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -257,3 +257,33 @@ TEST_F(CApiDatabaseTest, VirtualFileSystemDeleteFilesWindowsPaths) {
std::filesystem::remove_all("C:\\Desktop\\dir\\test1");
}
#endif

TEST_F(CApiDatabaseTest, VirtualFileSystemDeleteFilesWildcardNoRemoval) {
// Test Home Directory
std::string homeDir = "/tmp/dbHome_wildcard/";
kuzu::common::VirtualFileSystem vfs(homeDir);

// Setup files and directories
std::filesystem::create_directories("/tmp/dbHome_wildcard/test1_wildcard");
std::filesystem::create_directories("/tmp/dbHome_wildcard/test2_wildcard");
std::filesystem::create_directories("/tmp/dbHome_wildcard/nested_wildcard");
std::ofstream("/tmp/dbHome_wildcard/nested_wildcard/file1.txt").close();
std::ofstream("/tmp/dbHome_wildcard/nested_wildcard/file2.test").close();

// Attempt to remove files with wildcard pattern
try {
vfs.removeFileIfExists("/tmp/dbHome_wildcard/test*");
} catch (const kuzu::common::IOException& e) {
// Verify the exception is thrown for unsupported wildcard
EXPECT_STREQ(e.what(), "Error: Wildcard patterns are not supported in paths.");
}

// Verify files and directories still exist
ASSERT_TRUE(std::filesystem::exists("/tmp/dbHome_wildcard/test1_wildcard"));
ASSERT_TRUE(std::filesystem::exists("/tmp/dbHome_wildcard/test2_wildcard"));
ASSERT_TRUE(std::filesystem::exists("/tmp/dbHome_wildcard/nested_wildcard/file1.txt"));
ASSERT_TRUE(std::filesystem::exists("/tmp/dbHome_wildcard/nested_wildcard/file2.test"));

// Cleanup
std::filesystem::remove_all("/tmp/dbHome_wildcard");
}

0 comments on commit 7955894

Please sign in to comment.