Skip to content

Commit

Permalink
Add test for ConnectionHandler
Browse files Browse the repository at this point in the history
  • Loading branch information
kuznetsss committed Jan 10, 2025
1 parent 0273e8a commit baa6727
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions tests/unit/web/ng/impl/ConnectionHandlerTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -501,6 +501,33 @@ TEST_F(ConnectionHandlerSequentialProcessingTest, Stop)
});
}

TEST_F(ConnectionHandlerSequentialProcessingTest, ProcessCalledAfterStop)
{
testing::StrictMock<testing::MockFunction<
Response(Request const&, ConnectionMetadata const&, web::SubscriptionContextPtr, boost::asio::yield_context)>>
wsHandlerMock;
connectionHandler.onWs(wsHandlerMock.AsStdFunction());

runSyncOperation([this](boost::asio::yield_context yield) { connectionHandler.stop(yield); });

EXPECT_CALL(*mockWsConnection, wasUpgraded).WillOnce(Return(true));
EXPECT_CALL(
*mockWsConnection,
send(
testing::ResultOf(
[](Response const& r) { return r.message(); }, testing::HasSubstr("This Clio node is shutting down")
),
testing::_
)
);

EXPECT_CALL(*mockWsConnection, close);

runSpawn([this](boost::asio::yield_context yield) {
connectionHandler.processConnection(std::move(mockWsConnection), yield);
});
}

struct ConnectionHandlerParallelProcessingTest : ConnectionHandlerTest {
static constexpr size_t kMAX_PARALLEL_REQUESTS = 3;

Expand Down

0 comments on commit baa6727

Please sign in to comment.