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

@@ -17,6 +17,7 @@
*/
//==============================================================================
#include "util/MockAssert.hpp"
#include "util/prometheus/Counter.hpp"
#include "util/prometheus/Gauge.hpp"
#include "util/prometheus/Histogram.hpp"
@@ -32,7 +33,9 @@
using namespace util::prometheus;
TEST(MetricBuilderDeathTest, build)
struct MetricBuilderAssertTest : common::util::WithMockAssert {};
TEST_F(MetricBuilderAssertTest, build)
{
std::string const name = "name";
std::string const labelsString = "{label1=\"value1\"}";
@@ -80,5 +83,5 @@ TEST(MetricBuilderDeathTest, build)
EXPECT_EQ(metric->labelsString(), labelsString);
}
}
EXPECT_DEATH({ builder(name, labelsString, MetricType::Summary, std::vector<std::int64_t>{}); }, "");
EXPECT_CLIO_ASSERT_FAIL({ builder(name, labelsString, MetricType::Summary, std::vector<std::int64_t>{}); });
}