Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Chinmay1412 committed Apr 12, 2022
1 parent f1b8dc2 commit b74ba1b
Showing 1 changed file with 42 additions and 4 deletions.
46 changes: 42 additions & 4 deletions tests/amqpprox_session.t.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -908,8 +908,27 @@ TEST_F(SessionTest, Connect_Multiple_Dns)
EXPECT_CALL(d_selector, acquireConnection(_, _))
.WillOnce(DoAll(SetArgPointee<0>(d_cm), Return(0)));

TestSocketState::State base, clientBase;
testSetupHostnameMapperForServerClientBase(base, clientBase);
EXPECT_CALL(*d_mapper, prime(_, _)).Times(AtLeast(1));
EXPECT_CALL(*d_mapper, mapToHostname(makeEndpoint("2.3.4.5", 2345)))
.WillRepeatedly(Return(std::string("host1")));
EXPECT_CALL(*d_mapper, mapToHostname(makeEndpoint("1.2.3.4", 1234)))
.WillRepeatedly(Return(std::string("host0")));
EXPECT_CALL(*d_mapper, mapToHostname(makeEndpoint("1.2.3.4", 32000)))
.WillRepeatedly(Return(std::string("host0")));
EXPECT_CALL(*d_mapper, mapToHostname(makeEndpoint("3.4.5.6", 5672)))
.WillRepeatedly(Return(std::string("host2")));
EXPECT_CALL(*d_mapper, mapToHostname(makeEndpoint("0.0.0.0", 0)))
.WillRepeatedly(Return(std::string("<invalid>")));

TestSocketState::State base;
base.d_local = makeEndpoint("1.2.3.4", 1234);
base.d_remote = makeEndpoint("2.3.4.5", 2345);
base.d_secure = false;

TestSocketState::State clientBase;
clientBase.d_local = makeEndpoint("1.2.3.4", 32000);
clientBase.d_remote = makeEndpoint("3.4.5.6", 5672);
clientBase.d_secure = false;

// Initialise the state
d_serverState.pushItem(0, base);
Expand Down Expand Up @@ -1031,8 +1050,27 @@ TEST_F(SessionTest, Failover_Dns_Failure)
EXPECT_CALL(d_selector, acquireConnection(_, _))
.WillOnce(DoAll(SetArgPointee<0>(d_cm), Return(0)));

TestSocketState::State base, clientBase;
testSetupHostnameMapperForServerClientBase(base, clientBase);
EXPECT_CALL(*d_mapper, prime(_, _)).Times(AtLeast(1));
EXPECT_CALL(*d_mapper, mapToHostname(makeEndpoint("2.3.4.5", 2345)))
.WillRepeatedly(Return(std::string("host1")));
EXPECT_CALL(*d_mapper, mapToHostname(makeEndpoint("1.2.3.4", 1234)))
.WillRepeatedly(Return(std::string("host0")));
EXPECT_CALL(*d_mapper, mapToHostname(makeEndpoint("1.2.3.4", 32000)))
.WillRepeatedly(Return(std::string("host0")));
EXPECT_CALL(*d_mapper, mapToHostname(makeEndpoint("3.4.5.6", 5672)))
.WillRepeatedly(Return(std::string("host2")));
EXPECT_CALL(*d_mapper, mapToHostname(makeEndpoint("0.0.0.0", 0)))
.WillRepeatedly(Return(std::string("<invalid>")));

TestSocketState::State base;
base.d_local = makeEndpoint("1.2.3.4", 1234);
base.d_remote = makeEndpoint("2.3.4.5", 2345);
base.d_secure = false;

TestSocketState::State clientBase;
clientBase.d_local = makeEndpoint("1.2.3.4", 32000);
clientBase.d_remote = makeEndpoint("3.4.5.6", 5672);
clientBase.d_secure = false;

// Initialise the state
d_serverState.pushItem(0, base);
Expand Down

0 comments on commit b74ba1b

Please sign in to comment.