MCPcopy Create free account
hub / github.com/apache/arrow / TestOpenInputFileWithFileInfo

Method TestOpenInputFileWithFileInfo

cpp/src/arrow/filesystem/test_util.cc:1197–1236  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1195}
1196
1197void GenericFileSystemTest::TestOpenInputFileWithFileInfo(FileSystem* fs) {
1198 ASSERT_OK(fs->CreateDir("AB"));
1199 CreateFile(fs, "AB/abc", "some data");
1200
1201 ASSERT_OK_AND_ASSIGN(auto info, fs->GetFileInfo("AB/abc"));
1202
1203 ASSERT_OK_AND_ASSIGN(auto file, fs->OpenInputFile(info));
1204 ASSERT_OK_AND_EQ(9, file->GetSize());
1205 ASSERT_OK_AND_ASSIGN(auto buffer, file->Read(9));
1206 AssertBufferEqual(*buffer, "some data");
1207
1208 // Passing an incomplete FileInfo should also work
1209 info.set_type(FileType::Unknown);
1210 info.set_size(kNoSize);
1211 info.set_mtime(kNoTime);
1212 ASSERT_OK_AND_ASSIGN(file, fs->OpenInputFile(info));
1213 ASSERT_OK_AND_EQ(9, file->GetSize());
1214 ASSERT_OK_AND_ASSIGN(buffer, file->Read(4));
1215 AssertBufferEqual(*buffer, "some");
1216
1217 // File does not exist
1218 ASSERT_OK_AND_ASSIGN(info, fs->GetFileInfo("zzzzt"));
1219 AssertRaisesWithErrno(ENOENT, fs->OpenInputFile(info));
1220 // (same, with incomplete FileInfo)
1221 info.set_type(FileType::Unknown);
1222 AssertRaisesWithErrno(ENOENT, fs->OpenInputFile(info));
1223
1224 // Trailing slash rejected
1225 auto maybe_info = fs->GetFileInfo("AB/abc/");
1226 if (maybe_info.ok()) {
1227 ASSERT_OK_AND_ASSIGN(info, maybe_info);
1228 ASSERT_RAISES(IOError, fs->OpenInputFile(info));
1229 } else {
1230 ASSERT_RAISES(IOError, maybe_info);
1231 }
1232
1233 // Cannot open directory
1234 ASSERT_OK_AND_ASSIGN(info, fs->GetFileInfo("AB"));
1235 ASSERT_RAISES(IOError, fs->OpenInputFile(info));
1236}
1237
1238void GenericFileSystemTest::TestSpecialChars(FileSystem* fs) {
1239 ASSERT_OK(fs->CreateDir("Blank Char"));

Callers

nothing calls this directly

Calls 10

CreateFileFunction · 0.85
AssertBufferEqualFunction · 0.85
AssertRaisesWithErrnoFunction · 0.85
ASSERT_OK_AND_ASSIGNFunction · 0.70
CreateDirMethod · 0.45
GetSizeMethod · 0.45
OpenInputFileMethod · 0.45
ReadMethod · 0.45
GetFileInfoMethod · 0.45
okMethod · 0.45

Tested by

no test coverage detected