SVCS - English Documentation
Loading...
Searching...
No Matches
svcs::test::cli::utils::ClearCommandTest Class Reference

Test fixture for ClearCommand integration tests. More...

#include <ClearCommandTest.hxx>

Inheritance diagram for svcs::test::cli::utils::ClearCommandTest:

Protected Member Functions

void SetUp () override
 Sets up the test environment.
void TearDown () override
 Tears down the test environment.
void createTestFile (const std::string &filename, const std::string &content="test content") const
 Creates a test file inside the test directory.
void createTestDirectory (const std::string &dirname) const
 Creates a test directory inside the test directory.
void simulateUserInput (const std::string &input)
 Simulates user input by redirecting std::cin to a string stream.
bool repositoryExists () const
 Checks if the .svcs repository directory exists.

Protected Attributes

std::shared_ptr< MockSubjectmockEventBus
 Mock event bus for capturing system notifications.
std::shared_ptr< RepositoryManagerrepoManager
 Real RepositoryManager instance under test.
std::unique_ptr< ClearCommandcommand
 ClearCommand instance under test.
std::filesystem::path testDir
 Path to the temporary directory used as the repository root.
std::stringstream inputStream
 String stream used to feed simulated input to std::cin.
std::streambuf * originalCin
 Pointer to the original buffer of std::cin, saved for restoration.

Detailed Description

Test fixture for ClearCommand integration tests.

Manages the setup and teardown of a temporary, initialized SVCS repository. Provides utility methods to create test files/directories and to simulate user input required for the 'clear' confirmation prompt.

Member Function Documentation

◆ createTestDirectory()

void svcs::test::cli::utils::ClearCommandTest::createTestDirectory ( const std::string & dirname) const
protected

Creates a test directory inside the test directory.

Parameters
dirnameThe name of the directory to create.

◆ createTestFile()

void svcs::test::cli::utils::ClearCommandTest::createTestFile ( const std::string & filename,
const std::string & content = "test content" ) const
protected

Creates a test file inside the test directory.

Parameters
filenameThe name of the file to create.
contentThe content of the file (defaults to "test content").

◆ repositoryExists()

bool svcs::test::cli::utils::ClearCommandTest::repositoryExists ( ) const
protected

Checks if the .svcs repository directory exists.

Returns
true if the repository exists, false otherwise.

◆ SetUp()

void svcs::test::cli::utils::ClearCommandTest::SetUp ( )
overrideprotected

Sets up the test environment.

Creates and initializes a new temporary SVCS repository and saves the original std::cin buffer.

◆ simulateUserInput()

void svcs::test::cli::utils::ClearCommandTest::simulateUserInput ( const std::string & input)
protected

Simulates user input by redirecting std::cin to a string stream.

Parameters
inputThe string that will be read as user input.

◆ TearDown()

void svcs::test::cli::utils::ClearCommandTest::TearDown ( )
overrideprotected

Tears down the test environment.

Restores the original std::cin buffer and recursively removes the temporary directory.


The documentation for this class was generated from the following files: