6969namespace paimon ::test {
7070class GmockFileSystem : public LocalFileSystem {
7171 public:
72- GmockFileSystem () {
73- ON_CALL (*this , ListDir (testing::_, testing::_))
74- .WillByDefault (testing::Invoke (
75- [&](const std::string& directory,
76- std::vector<std::unique_ptr<BasicFileStatus>>* file_status_list) {
77- return this ->LocalFileSystem ::ListDir (directory, file_status_list);
78- }));
79- ON_CALL (*this , ReadFile (testing::_, testing::_))
80- .WillByDefault (testing::Invoke ([&](const std::string& path, std::string* content) {
81- return this ->FileSystem ::ReadFile (path, content);
82- }));
83- ON_CALL (*this , AtomicStore (::testing::_, ::testing::_))
84- .WillByDefault (
85- testing::Invoke ([&](const std::string& path, const std::string& content) {
86- return this ->FileSystem ::AtomicStore (path, content);
87- }));
88- }
89-
9072 MOCK_METHOD (Status, ReadFile, (const std::string& path, std::string* content), (override ));
9173 MOCK_METHOD (Status, ListDir,
9274 (const std::string& directory,
@@ -105,31 +87,30 @@ class GmockFileSystemFactory : public LocalFileSystemFactory {
10587 Result<std::unique_ptr<FileSystem>> Create (
10688 const std::string& path, const std::map<std::string, std::string>& options) const override {
10789 return std::make_unique<testing::NiceMock<GmockFileSystem>>();
108- // auto fs = std::make_unique<testing::NiceMock<GmockFileSystem>>();
109- // auto fs_ptr = fs.get();
110- // using ::testing::A;
111- // using ::testing::Invoke;
112-
113- // ON_CALL(*fs, ListDir(A<const std::string&>(),
114- // A<std::vector<std::unique_ptr<BasicFileStatus>>*>()))
115- // .WillByDefault(
116- // Invoke([fs_ptr](const std::string& directory,
117- // std::vector<std::unique_ptr<BasicFileStatus>>* file_status_list)
118- // {
119- // return fs_ptr->LocalFileSystem::ListDir(directory, file_status_list);
120- // }));
121-
122- // ON_CALL(*fs, ReadFile(A<const std::string&>(), A<std::string*>()))
123- // .WillByDefault(Invoke([fs_ptr](const std::string& path, std::string* content) {
124- // return fs_ptr->FileSystem::ReadFile(path, content);
125- // }));
126-
127- // ON_CALL(*fs, AtomicStore(A<const std::string&>(), A<const std::string&>()))
128- // .WillByDefault(Invoke([fs_ptr](const std::string& path, const std::string& content) {
129- // return fs_ptr->FileSystem::AtomicStore(path, content);
130- // }));
131-
132- // return fs;
90+ auto fs = std::make_unique<testing::NiceMock<GmockFileSystem>>();
91+ auto fs_ptr = fs.get ();
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 ([fs_ptr](const std::string& directory,
99+ std::vector<std::unique_ptr<BasicFileStatus>>* file_status_list) {
100+ return fs_ptr->LocalFileSystem ::ListDir (directory, file_status_list);
101+ }));
102+
103+ ON_CALL (*fs, ReadFile (A<const std::string&>(), A<std::string*>()))
104+ .WillByDefault (Invoke ([fs_ptr](const std::string& path, std::string* content) {
105+ return fs_ptr->FileSystem ::ReadFile (path, content);
106+ }));
107+
108+ ON_CALL (*fs, AtomicStore (A<const std::string&>(), A<const std::string&>()))
109+ .WillByDefault (Invoke ([fs_ptr](const std::string& path, const std::string& content) {
110+ return fs_ptr->FileSystem ::AtomicStore (path, content);
111+ }));
112+
113+ return fs;
133114 }
134115};
135116
0 commit comments