test: Add assert mock to avoid death tests (#1947)

Fixes #1750
This commit is contained in:
Sergey Kuznetsov
2025-03-07 18:11:52 +00:00
committed by GitHub
parent 8a08c5e6ce
commit c57fe1e6e4
30 changed files with 411 additions and 295 deletions

View File

@@ -19,6 +19,7 @@
#include "migration/cassandra/impl/FullTableScanner.hpp"
#include "util/LoggerFixtures.hpp"
#include "util/MockAssert.hpp"
#include <boost/asio/spawn.hpp>
#include <gmock/gmock.h>
@@ -51,30 +52,32 @@ struct TestScannerAdaper {
};
} // namespace
struct FullTableScannerTests : public NoLoggerFixture {};
struct FullTableScannerAssertTest : common::util::WithMockAssert {};
TEST_F(FullTableScannerTests, workerNumZero)
TEST_F(FullTableScannerAssertTest, workerNumZero)
{
testing::MockFunction<void(migration::cassandra::impl::TokenRange const&, boost::asio::yield_context)> mockCallback;
EXPECT_DEATH(
EXPECT_CLIO_ASSERT_FAIL_WITH_MESSAGE(
migration::cassandra::impl::FullTableScanner<TestScannerAdaper>(
{.ctxThreadsNum = 1, .jobsNum = 0, .cursorsPerJob = 100}, TestScannerAdaper(mockCallback)
),
"jobsNum for full table scanner must be greater than 0"
".*jobsNum for full table scanner must be greater than 0"
);
}
TEST_F(FullTableScannerTests, cursorsPerWorkerZero)
TEST_F(FullTableScannerAssertTest, cursorsPerWorkerZero)
{
testing::MockFunction<void(migration::cassandra::impl::TokenRange const&, boost::asio::yield_context)> mockCallback;
EXPECT_DEATH(
EXPECT_CLIO_ASSERT_FAIL_WITH_MESSAGE(
migration::cassandra::impl::FullTableScanner<TestScannerAdaper>(
{.ctxThreadsNum = 1, .jobsNum = 1, .cursorsPerJob = 0}, TestScannerAdaper(mockCallback)
),
"cursorsPerJob for full table scanner must be greater than 0"
".*cursorsPerJob for full table scanner must be greater than 0"
);
}
struct FullTableScannerTests : NoLoggerFixture {};
TEST_F(FullTableScannerTests, SingleThreadCtx)
{
testing::MockFunction<void(migration::cassandra::impl::TokenRange const&, boost::asio::yield_context)> mockCallback;