userver: utest Namespace Reference
Loading...
Searching...
No Matches
utest Namespace Reference

Detailed Description

Mocks and test helpers.

Classes

class  DefaultLoggerFixture
 Fixture that allows to set the default logger and manages its lifetime. More...
 
class  DnsServerMock
 
class  HttpServerMock
 
class  LogCaptureFixture
 Fixture that allows to capture and extract log written into the default logger. More...
 
class  LogCaptureLogger
 A mocked logger that stores the log records in memory. More...
 
class  LogRecord
 Represents single log record, typically written via LOG_* macros. More...
 
class  NotSingleLogError
 Thrown by GetSingleLog. More...
 
struct  PrintTestName
 Test name printer for parameterized tests written in gtest. More...
 
class  SimpleServer
 

Functions

constexpr std::chrono::seconds kMaxTestWaitTime (20)
 
std::vector< std::string > CurrentProcessOpenFiles ()
 returns files opened by current process
 
std::ostream & operator<< (std::ostream &, const LogRecord &data)
 
std::ostream & operator<< (std::ostream &, const std::vector< LogRecord > &data)
 
LogRecord GetSingleLog (utils::span< const LogRecord > log, const utils::impl::SourceLocation &source_location=utils::impl::SourceLocation::Current())
 
std::shared_ptr< clients::http::ClientCreateHttpClient ()
 
std::shared_ptr< clients::http::ClientCreateHttpClient (engine::TaskProcessor &fs_task_processor)
 
std::shared_ptr< clients::http::ClientCreateHttpClient (const tracing::TracingManagerBase &tracing_manager)
 

Function Documentation

◆ CurrentProcessOpenFiles()

std::vector< std::string > utest::CurrentProcessOpenFiles ( )

returns files opened by current process

jemalloc opens /proc/sys/vm/overcommit_memory, other libraries may also open some files randomly. To avoid problems in tests and make them reliable check files for specific prefix.

◆ GetSingleLog()

LogRecord utest::GetSingleLog ( utils::span< const LogRecord > log,
const utils::impl::SourceLocation & source_location = utils::impl::SourceLocation::Current() )
Returns
the only log record from log.
Exceptions
NotSingleLogErrorif there are zero or multiple log records.

◆ kMaxTestWaitTime()

constexpr std::chrono::seconds utest::kMaxTestWaitTime ( 20 )
inlineconstexpr

The maximum time a typical test is allowed to execute. If exceeded, a deadlock is assumed. This time must not be too low to avoid flaky tests.