ifw-daq  3.0.0-pre2
IFW Data Acquisition modules
testPendingReplies.cpp
Go to the documentation of this file.
1 /**
2  * @file
3  * @ingroup daq_ocm_libdaq_test
4  * @copyright 2022 ESO - European Southern Observatory
5  *
6  * @brief Tests for PendingReplies and related
7  */
8 #include <daq/pendingReplies.hpp>
9 
10 #include <gtest/gtest.h>
11 #include <gmock/gmock.h>
12 
13 using namespace ::testing;
14 using namespace ::daq;
15 
16 /**
17  * Test fixture for PendingReplies tests.
18  *
19  * @ingroup daq_ocm_libdaq_test
20  */
21 class TestPendingReplies : public ::testing::Test {
22 public:
23  void SetUp() override {
24  pending = PendingReplies::Create();
25  }
26  void TearDown() override {
27  }
28 protected:
29  std::shared_ptr<PendingReplies> pending;
30 };
31 
32 TEST_F(TestPendingReplies, DeletedReplyTokenReleasesPendingReply) {
33  EXPECT_FALSE(pending->HasPendingReplies());
34  {
35  auto token = pending->Acquire("id", "req");
36  EXPECT_TRUE(pending->HasPendingReplies());
37  }
38  EXPECT_FALSE(pending->HasPendingReplies());
39 }
40 
41 TEST_F(TestPendingReplies, PendingReplyReleasesTheCorrectToken) {
42  EXPECT_FALSE(pending->HasPendingReplies());
43  {
44  auto token = pending->Acquire("1", "req");
45  {
46  auto token2 = pending->Acquire("2", "req");
47  }
48  auto token3 = pending->Acquire("3", "req");
49  auto pending_vec = pending->GetPendingReplies();
50 
51  ASSERT_EQ(2u, pending_vec.size());
52  std::vector<PendingReplies::PendingReply> expected = {{"1", "req"}, {"3", "req"}};
53  //EXPECT_THAT(pending_vec, UnorderedElementsAre(expected));
54  }
55  EXPECT_FALSE(pending->HasPendingReplies());
56 }
void TearDown() override
std::shared_ptr< PendingReplies > pending
Test fixture for PendingReplies tests.
Contains declaration for classes related to pending replies.
TEST_F(TestPendingReplies, DeletedReplyTokenReleasesPendingReply)
ASSERT_EQ(meta.keyword_rules.size(), 1u)