coryan commented on a change in pull request #11550:
URL: https://github.com/apache/arrow/pull/11550#discussion_r743105900
##########
File path: cpp/src/arrow/filesystem/gcsfs_test.cc
##########
@@ -259,6 +352,55 @@ TEST_F(GcsIntegrationTest, ReadObjectInfoInvalid) {
EXPECT_EQ(result.status().code(), StatusCode::IOError);
}
+TEST_F(GcsIntegrationTest, WriteObjectSmall) {
+ auto fs = internal::MakeGcsFileSystemForTest(TestGcsOptions());
+
+ const auto path = kPreexistingBucket + std::string("/test-write-object");
+ std::shared_ptr<io::OutputStream> output;
+ ASSERT_OK_AND_ASSIGN(output, fs->OpenOutputStream(path, {}));
+ const auto expected = std::string(kLoremIpsum);
+ ASSERT_OK(output->Write(expected.data(), expected.size()));
+ ASSERT_OK(output->Close());
+
+ // Verify we can read the object back.
+ std::shared_ptr<io::InputStream> input;
+ ASSERT_OK_AND_ASSIGN(input, fs->OpenInputStream(path));
+
+ std::array<char, 1024> inbuf{};
+ std::int64_t size;
+ ASSERT_OK_AND_ASSIGN(size, input->Read(inbuf.size(), inbuf.data()));
+
+ EXPECT_EQ(std::string(inbuf.data(), size), expected);
+}
+
+TEST_F(GcsIntegrationTest, WriteObjectLarge) {
+ auto fs = internal::MakeGcsFileSystemForTest(TestGcsOptions());
+
+ const auto path = kPreexistingBucket + std::string("/test-write-object");
+ std::shared_ptr<io::OutputStream> output;
+ ASSERT_OK_AND_ASSIGN(output, fs->OpenOutputStream(path, {}));
+ const auto b0 = std::string(512 * 1024, 'A');
+ const auto b1 = std::string(768 * 1024, 'B');
+ const auto b2 = std::string(1024 * 1024, 'C');
+ ASSERT_OK(output->Write(b0.data(), b0.size()));
+ ASSERT_OK(output->Write(b1.data(), b1.size()));
+ ASSERT_OK(output->Write(b2.data(), b2.size()));
+ ASSERT_OK(output->Close());
+
+ // Verify we can read the object back.
+ std::shared_ptr<io::InputStream> input;
+ ASSERT_OK_AND_ASSIGN(input, fs->OpenInputStream(path));
+
+ std::string contents;
+ std::shared_ptr<Buffer> buffer;
+ do {
+ ASSERT_OK_AND_ASSIGN(buffer, input->Read(128 * 1024));
+ contents.append(buffer->ToString());
+ } while (buffer && buffer->size() != 0);
Review comment:
Fixed.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]