lordgamez commented on code in PR #2269:
URL: https://github.com/apache/nifi-minifi-cpp/pull/2269#discussion_r4181554121


##########
libminifi/test/libtest/unit/TestUtils.h:
##########
@@ -69,6 +71,41 @@ std::string getFileContent(const std::filesystem::path& 
file_name);
 void makeFileOrDirectoryNotWritable(const std::filesystem::path& file_name);
 void makeFileOrDirectoryWritable(const std::filesystem::path& file_name);
 
+/**
+ * Sets an environment variable for the lifetime of the object, and restores 
its previous value (or unsets it, if it was
+ * not set before) on destruction. Pass std::nullopt as the value to make sure 
the variable is not set in the scope.
+ * Environment variables are process-global, so tests that rely on them need 
to clean up after themselves.

Review Comment:
   For example the default credential chains goes through the available 
credential options like access keys, profile credentials, instance profile, 
session tokens, and these credentials options can also be set in environment 
variables. We expect a specific credential to be used when we run a test and if 
we set another one in a previous test it could be prioritized and found in the 
default chain instead of the one we expect to be found, so it's better to clear 
all of them at the beginning especially as the order of the tests is randomized.



-- 
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]

Reply via email to