@@ -88,29 +88,35 @@ class GmockFileSystemFactory : public LocalFileSystemFactory {
8888
8989 Result<std::unique_ptr<FileSystem>> Create (
9090 const std::string& path, const std::map<std::string, std::string>& options) const override {
91- return std::make_unique<GmockFileSystem>();
91+ auto fs = std::make_unique<GmockFileSystem>();
92+ using ::testing::A;
93+ using ::testing::Invoke;
94+
95+ ON_CALL (*fs, ListDir (A<const std::string&>(),
96+ A<std::vector<std::unique_ptr<BasicFileStatus>>*>()))
97+ .WillByDefault (
98+ Invoke ([&](const std::string& directory,
99+ std::vector<std::unique_ptr<BasicFileStatus>>* file_status_list) {
100+ return fs->LocalFileSystem ::ListDir (directory, file_status_list);
101+ }));
102+
103+ ON_CALL (*fs, ReadFile (A<const std::string&>(), A<std::string*>()))
104+ .WillByDefault (Invoke ([&](const std::string& path, std::string* content) {
105+ return fs->FileSystem ::ReadFile (path, content);
106+ }));
107+
108+ ON_CALL (*fs, AtomicStore (A<const std::string&>(), A<const std::string&>()))
109+ .WillByDefault (Invoke ([&](const std::string& path, const std::string& content) {
110+ return fs->FileSystem ::AtomicStore (path, content);
111+ }));
112+
113+ return fs;
92114 }
93115};
94116
95117class FileStoreCommitImplTest : public testing ::Test {
96118 public:
97119 void SetUp () override {
98- ON_CALL (*this , ListDir (testing::_, testing::_))
99- .WillByDefault (testing::Invoke (
100- [&](const std::string& directory,
101- std::vector<std::unique_ptr<BasicFileStatus>>* file_status_list) {
102- return this ->LocalFileSystem ::ListDir (directory, file_status_list);
103- }));
104- ON_CALL (*this , ReadFile (testing::_, testing::_))
105- .WillByDefault (testing::Invoke ([&](const std::string& path, std::string* content) {
106- return this ->FileSystem ::ReadFile (path, content);
107- }));
108- ON_CALL (*this , AtomicStore (::testing::_, ::testing::_))
109- .WillByDefault (
110- testing::Invoke ([&](const std::string& path, const std::string& content) {
111- return this ->FileSystem ::AtomicStore (path, content);
112- }));
113-
114120 auto factory_creator = paimon::FactoryCreator::GetInstance ();
115121 factory_creator->Register (" gmock_fs" , (new GmockFileSystemFactory));
116122 dir_ = UniqueTestDirectory::Create ();
0 commit comments