adamdebreceni commented on a change in pull request #976:
URL: https://github.com/apache/nifi-minifi-cpp/pull/976#discussion_r559359251
##########
File path: extensions/windows-event-log/tests/ConsumeWindowsEventLogTests.cpp
##########
@@ -300,53 +330,249 @@ TEST_CASE("ConsumeWindowsEventLog output format can be
set", "[create][output_fo
outputFormatSetterTestHelper("InvalidValue", 0);
}
+namespace {
+
+class OutputFormatTestController : public TestController {
+ public:
+ OutputFormatTestController(std::string channel, std::string query,
std::string output_format)
+ : channel_(std::move(channel)),
+ query_(std::move(query)),
+ output_format_(std::move(output_format)) {}
+
+ std::string run() {
+ LogTestController::getInstance().setDebug<ConsumeWindowsEventLog>();
+ LogTestController::getInstance().setDebug<LogAttribute>();
+ std::shared_ptr<TestPlan> test_plan = createPlan();
+
+ auto cwel_processor = test_plan->addProcessor("ConsumeWindowsEventLog",
"cwel");
+ test_plan->setProperty(cwel_processor,
ConsumeWindowsEventLog::Channel.getName(), channel_);
+ test_plan->setProperty(cwel_processor,
ConsumeWindowsEventLog::Query.getName(), query_);
+ test_plan->setProperty(cwel_processor,
ConsumeWindowsEventLog::OutputFormat.getName(), output_format_);
+
+ auto dir = utils::createTempDir(this);
+
+ auto put_file = test_plan->addProcessor("PutFile", "putFile", Success,
true);
+ test_plan->setProperty(put_file, PutFile::Directory.getName(), dir);
+
+ {
+ dispatchBookmarkEvent();
+
+ runSession(test_plan);
+ }
+
+ test_plan->reset();
+
LogTestController::getInstance().resetStream(LogTestController::getInstance().log_output);
+
+
+ {
+ dispatchCollectedEvent();
+
+ runSession(test_plan);
+
+ auto files = utils::file::list_dir_all(dir,
LogTestController::getInstance().getLogger<LogTestController>(), false);
+ REQUIRE(files.size() == 1);
+
+ std::ifstream file{utils::file::concat_path(files[0].first,
files[0].second)};
+ return {std::istreambuf_iterator<char>{file}, {}};
+ }
+ }
+
+ protected:
+ virtual void dispatchBookmarkEvent() = 0;
+ virtual void dispatchCollectedEvent() = 0;
+
+ std::string channel_;
+ std::string query_;
+ std::string output_format_;
+};
+
+} // namespace
+
// NOTE(fgerlits): I don't know how to unit test this, as my manually
published events all result in an empty string if OutputFormat is Plaintext
// but it does seem to work, based on manual tests reading
system logs
// TEST_CASE("ConsumeWindowsEventLog prints events in plain text correctly",
"[onTrigger]")
Review comment:
I will check it!
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]