fgerlits commented on a change in pull request #791:
URL: https://github.com/apache/nifi-minifi-cpp/pull/791#discussion_r435325700



##########
File path: extensions/standard-processors/tests/unit/TailFileTests.cpp
##########
@@ -47,7 +47,33 @@ static std::string NEWLINE_FILE = ""  // NOLINT
 static const char *TMP_FILE = "minifi-tmpfile.txt";
 static const char *STATE_FILE = "minifi-state-file.txt";
 
-TEST_CASE("TailFileWithDelimiter", "[tailfiletest2]") {
+namespace {
+  std::string createTempFile(const std::string &directory, const std::string 
&file_name, const std::string &contents,
+      std::ios_base::openmode open_mode = std::ios::out | std::ios::binary) {
+    std::string full_file_name = directory + 
utils::file::FileUtils::get_separator() + file_name;
+    std::ofstream tmpfile{full_file_name, open_mode};
+    tmpfile << contents;
+    return full_file_name;
+  }
+
+  void appendTempFile(const std::string &directory, const std::string 
&file_name, const std::string &contents,
+      std::ios_base::openmode open_mode = std::ios::app | std::ios::binary) {
+    createTempFile(directory, file_name, contents, open_mode);
+  }
+
+  void removeFile(const std::string &directory, const std::string &file_name) {
+    std::string full_file_name = directory + 
utils::file::FileUtils::get_separator() + file_name;
+    std::remove(full_file_name.c_str());
+  }
+
+  void renameTempFile(const std::string &directory, const std::string 
&old_file_name, const std::string &new_file_name) {
+    std::string old_full_file_name = directory + 
utils::file::FileUtils::get_separator() + old_file_name;
+    std::string new_full_file_name = directory + 
utils::file::FileUtils::get_separator() + new_file_name;
+    rename(old_full_file_name.c_str(), new_full_file_name.c_str());
+  }
+}  // namespace

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.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to