drin commented on code in PR #13383: URL: https://github.com/apache/arrow/pull/13383#discussion_r899683441
########## cpp/src/arrow/record_batch_test.cc: ########## @@ -388,6 +389,34 @@ class TestRecordBatchReader : public ::testing::Test { std::shared_ptr<RecordBatchReader> reader_; }; +// A minimal class to test Status::Warn() +class UncloseableReader : public RecordBatchReader { + public: + UncloseableReader(RecordBatchVector batches, std::shared_ptr<Schema> schema) + : schema_(std::move(schema)), it_(MakeVectorIterator(std::move(batches))) {} + + ~UncloseableReader() { ARROW_WARN_NOT_OK(Close(), "Expect: uncloseable reader"); } + + Status ReadNext(std::shared_ptr<RecordBatch>* batch) override { + return it_.Next().Value(batch); + } + + std::shared_ptr<Schema> schema() const override { return schema_; } + + Status Close() override { return Status::Invalid("uncloseable reader"); } + + protected: + std::shared_ptr<Schema> schema_; + RecordBatchIterator it_; +}; + +TEST_F(TestRecordBatchReader, CloseAndWarn) { + auto uncloseable_reader_ = + std::make_shared<UncloseableReader>(batches_, reader_->schema()); + + ASSERT_EQ(Status::Invalid("uncloseable reader"), uncloseable_reader_->Close()); +} Review Comment: That's reasonable. I can do that instead. -- 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: github-unsubscr...@arrow.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org