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

Method TestOpenInputStreamWithFileInfo

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

Source from the content-addressed store, hash-verified

1082}
1083
1084void GenericFileSystemTest::TestOpenInputStreamWithFileInfo(FileSystem* fs) {
1085 ASSERT_OK(fs->CreateDir("AB"));
1086 CreateFile(fs, "AB/abc", "some data");
1087
1088 ASSERT_OK_AND_ASSIGN(auto info, fs->GetFileInfo("AB/abc"));
1089
1090 ASSERT_OK_AND_ASSIGN(auto stream, fs->OpenInputStream(info));
1091 ASSERT_OK_AND_ASSIGN(auto buffer, stream->Read(9));
1092 AssertBufferEqual(*buffer, "some data");
1093
1094 // Passing an incomplete FileInfo should also work
1095 info.set_type(FileType::Unknown);
1096 info.set_size(kNoSize);
1097 info.set_mtime(kNoTime);
1098 ASSERT_OK_AND_ASSIGN(stream, fs->OpenInputStream(info));
1099 ASSERT_OK_AND_ASSIGN(buffer, stream->Read(4));
1100 AssertBufferEqual(*buffer, "some");
1101
1102 // File does not exist
1103 ASSERT_OK_AND_ASSIGN(info, fs->GetFileInfo("zzzzt"));
1104 AssertRaisesWithErrno(ENOENT, fs->OpenInputStream(info));
1105 // (same, with incomplete FileInfo)
1106 info.set_type(FileType::Unknown);
1107 AssertRaisesWithErrno(ENOENT, fs->OpenInputStream(info));
1108
1109 // Trailing slash rejected
1110 auto maybe_info = fs->GetFileInfo("AB/abc/");
1111 if (maybe_info.ok()) {
1112 ASSERT_OK_AND_ASSIGN(info, maybe_info);
1113 ASSERT_RAISES(IOError, fs->OpenInputStream(info));
1114 } else {
1115 ASSERT_RAISES(IOError, maybe_info);
1116 }
1117
1118 // Cannot open directory
1119 ASSERT_OK_AND_ASSIGN(info, fs->GetFileInfo("AB"));
1120 ASSERT_RAISES(IOError, fs->OpenInputStream(info));
1121}
1122
1123void GenericFileSystemTest::TestOpenInputStreamAsync(FileSystem* fs) {
1124 ASSERT_OK(fs->CreateDir("AB"));

Callers

nothing calls this directly

Calls 9

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

Tested by

no test coverage detected