fgerlits commented on code in PR #1411:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1411#discussion_r958433855


##########
libminifi/test/unit/ResourceQueueTests.cpp:
##########
@@ -53,23 +55,26 @@ TEST_CASE("maximum_number_of_creatable_resources", 
"[utils::ResourceQueue]") {
     CHECK(!resources_created.empty());
     CHECK(resources_created.size() <= 2);
   }
+}
 
-  SECTION("No Maximum resources") {
-    LogTestController::getInstance().clear();
-    auto resource_queue = ResourceQueue<int>::create(std::nullopt, logger_);
-    std::thread thread_one{[&] { worker(1, resource_queue); }};
-    std::thread thread_two{[&] { worker(2, resource_queue); }};
-    std::thread thread_three{[&] { worker(3, resource_queue); }};
+TEST_CASE("Resource limitation is not set to the resource queue", 
"[utils::ResourceQueue]") {
+  std::shared_ptr<core::logging::Logger> 
logger_{core::logging::LoggerFactory<ResourceQueue<int>>::getLogger()};
+  LogTestController::getInstance().setTrace<ResourceQueue<int>>();
+  LogTestController::getInstance().clear();
+  auto resource_queue = ResourceQueue<int>::create(std::nullopt, logger_);
+  std::set<int> resources_created;
 
-    thread_one.join();
-    thread_two.join();
-    thread_three.join();
+  auto resource_one = resource_queue->getResource([]{return 
std::make_unique<int>(1);});
+  auto resource_two = resource_queue->getResource([]{return 
std::make_unique<int>(2);});
+  auto resource_three = resource_queue->getResource([]{return 
std::make_unique<int>(3);});
 
-    CHECK(!resources_created.empty());
-    CHECK(!LogTestController::getInstance().contains("Waiting for resource", 
0ms));
-    CHECK(LogTestController::getInstance().contains("Number of instances: 3", 
0ms));
-    CHECK(resources_created.size() <= 3);
-  }
+  resources_created.emplace(*resource_one);
+  resources_created.emplace(*resource_two);
+  resources_created.emplace(*resource_three);

Review Comment:
   OK, I see.  To me, the shorter version would be clearer, but I don't mind 
keeping the extra check.



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