RTC Toolkit 6.0.0
Loading...
Searching...
No Matches

Provides an in-memory OLDB for unit testing. More...

Files

file  inMemoryOldb.hpp
 Header file with support routines for preparing an in-memory OLDB instance for testing.
 
file  inMemoryOldb.cpp
 Implementation of support functions to provide an in-memory OLDB for testing.
 

Functions

OldbCreationResult rtctk::componentFramework::test::CreateInMemoryOldbWithExtRedis ()
 This function prepares an in-memory OLDB with fake external Redis providers for unit testing.
 
std::shared_ptr< elt::oldb::CiiOldb > rtctk::componentFramework::test::CreateInMemoryOldb ()
 This function prepares an in-memory OLDB that is suitable for unit testing.
 
void rtctk::componentFramework::test::DeleteAllConfigDataPoints (const std::string &target_config_storage=elt::oldb::CiiOldbGlobal::CONFIG_STORAGE_CACHE)
 Deletes all configuration datapoints in the CII configuration service.
 

Detailed Description

Provides an in-memory OLDB for unit testing.

The primary purpose of this library is to allow testing the OldbAdapter. The in-memory OLD has been placed into its own library with no dependencies on other RTC Toolkit code to avoid dependency cycles between the library that provides the OldbAdapter and the corresponding test support library for OldbIf.

Function Documentation

◆ CreateInMemoryOldb()

std::shared_ptr< elt::oldb::CiiOldb > rtctk::componentFramework::test::CreateInMemoryOldb ( )

This function prepares an in-memory OLDB that is suitable for unit testing.

The in-memory OLDB is a fake, but should reproduce most OLDB behaviour as expected by the OldbAdapter and RuntimeRepoAdapter.

◆ CreateInMemoryOldbWithExtRedis()

OldbCreationResult rtctk::componentFramework::test::CreateInMemoryOldbWithExtRedis ( )

This function prepares an in-memory OLDB with fake external Redis providers for unit testing.

The created in-memory OLDB will contain two additional fake external Redis providers that should reproduce most of the OLDB external Redis behaviour as expected by the RuntimeRepoAdapter.

The result of this method will contain two pointers to mock interfaces for the external Redis backend. These can be used to check that the correct external Redis was called. See the following code for example:

auto [oldb, ext_redis_1, ext_redis_2] = CreateInMemoryOldbWithExtRedis();
RuntimeRepoAdapter repo(elt::mal::Uri("cii.oldb:/rtctktest"), oldb);
EXPECT_CALL(*ext_redis_1, WriteDataPoint("cii.oldb:/rtctktest/datapoint1")).Times(1);
EXPECT_CALL(*ext_redis_2, WriteDataPoint("cii.oldb:/rtctktest/datapoint2")).Times(1);
repo.CreateDataPoint("/datapoint1"_dppath, std::string("test value"), "extRedis1");
repo.CreateDataPoint("/datapoint2"_dppath, static_cast<int32_t>(123), "extRedis2");
Implementation of the Runtime Configuration Repository Adapter.
Definition runtimeRepoAdapter.hpp:30
OldbCreationResult CreateInMemoryOldbWithExtRedis()
This function prepares an in-memory OLDB with fake external Redis providers for unit testing.
Definition inMemoryOldb.cpp:80
Returns
A tuple containing shared pointers to the oldb and mock interfaces representing the two backend external Redis providers, i.e. std::make_tuple(oldb, ext_redis_1, ext_redis_2).

◆ DeleteAllConfigDataPoints()

void rtctk::componentFramework::test::DeleteAllConfigDataPoints ( const std::string & target_config_storage = elt::oldb::CiiOldbGlobal::CONFIG_STORAGE_CACHE)

Deletes all configuration datapoints in the CII configuration service.

The function will recursively go through the entire configuration datapoint hierarchy in the CII configuration service and deletes all datapoints.

Parameters
[in]target_config_storageThe target configuration to clear. By default this is the in-memory "cache" storage.