From baa6727abd433a730a8077eae5898a10536efb65 Mon Sep 17 00:00:00 2001 From: Sergey Kuznetsov Date: Fri, 10 Jan 2025 13:07:50 +0000 Subject: [PATCH] Add test for ConnectionHandler --- .../web/ng/impl/ConnectionHandlerTests.cpp | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/tests/unit/web/ng/impl/ConnectionHandlerTests.cpp b/tests/unit/web/ng/impl/ConnectionHandlerTests.cpp index 148a15d78..8036fed37 100644 --- a/tests/unit/web/ng/impl/ConnectionHandlerTests.cpp +++ b/tests/unit/web/ng/impl/ConnectionHandlerTests.cpp @@ -501,6 +501,33 @@ TEST_F(ConnectionHandlerSequentialProcessingTest, Stop) }); } +TEST_F(ConnectionHandlerSequentialProcessingTest, ProcessCalledAfterStop) +{ + testing::StrictMock> + 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;