|
24 | 24 | #include <arrow/filesystem/localfs.h> |
25 | 25 | #include <gtest/gtest.h> |
26 | 26 |
|
| 27 | +#include "matchers.h" |
| 28 | + |
| 29 | +namespace iceberg { |
| 30 | + |
27 | 31 | class LocalFileIOTest : public testing::Test { |
28 | 32 | protected: |
29 | 33 | void SetUp() override { |
30 | | - local_fs_ = std::make_shared<arrow::fs::LocalFileSystem>(); |
| 34 | + local_fs_ = std::make_shared<::arrow::fs::LocalFileSystem>(); |
31 | 35 | file_io_ = std::make_shared<iceberg::arrow::io::ArrowFileSystemFileIO>(local_fs_); |
32 | 36 | } |
33 | 37 |
|
34 | | - std::shared_ptr<arrow::fs::LocalFileSystem> local_fs_; |
| 38 | + std::shared_ptr<::arrow::fs::LocalFileSystem> local_fs_; |
35 | 39 | std::shared_ptr<iceberg::FileIO> file_io_; |
36 | 40 | std::filesystem::path tmpfile = std::filesystem::temp_directory_path() / "123.txt"; |
37 | 41 | }; |
38 | 42 |
|
39 | 43 | TEST_F(LocalFileIOTest, ReadWriteFile) { |
40 | 44 | auto read_res = file_io_->ReadFile(tmpfile.string(), 1024); |
41 | | - EXPECT_EQ(read_res.error().kind, iceberg::ErrorKind::kInvalidArgument); |
| 45 | + EXPECT_THAT(read_res, IsError(ErrorKind::kInvalidArgument)); |
| 46 | + EXPECT_THAT(read_res, HasErrorMessage("Length is not supported")); |
42 | 47 |
|
43 | 48 | read_res = file_io_->ReadFile(tmpfile.string(), std::nullopt); |
44 | | - EXPECT_EQ(read_res.error().kind, iceberg::ErrorKind::kIOError); |
| 49 | + EXPECT_THAT(read_res, IsError(ErrorKind::kIOError)); |
| 50 | + EXPECT_THAT(read_res, HasErrorMessage("No such file or directory")); |
45 | 51 |
|
46 | 52 | auto write_res = file_io_->WriteFile(tmpfile.string(), "hello world", false); |
47 | | - EXPECT_TRUE(write_res.has_value()); |
| 53 | + EXPECT_THAT(write_res, IsOk()); |
48 | 54 |
|
49 | 55 | read_res = file_io_->ReadFile(tmpfile.string(), std::nullopt); |
| 56 | + EXPECT_THAT(read_res, IsOk()); |
50 | 57 | EXPECT_EQ(read_res.value(), "hello world"); |
51 | 58 | } |
52 | 59 |
|
53 | 60 | TEST_F(LocalFileIOTest, DeleteFile) { |
54 | 61 | auto del_res = file_io_->DeleteFile(tmpfile.string()); |
55 | | - EXPECT_TRUE(del_res.has_value()); |
| 62 | + EXPECT_THAT(del_res, IsOk()); |
56 | 63 |
|
57 | 64 | del_res = file_io_->DeleteFile(tmpfile.string()); |
58 | | - EXPECT_EQ(del_res.error().kind, iceberg::ErrorKind::kIOError); |
| 65 | + EXPECT_THAT(del_res, IsError(ErrorKind::kIOError)); |
| 66 | + EXPECT_THAT(del_res, HasErrorMessage("No such file or directory")); |
59 | 67 | } |
| 68 | + |
| 69 | +} // namespace iceberg |
0 commit comments