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

Google Test fixture for running integration tests against the HistoryCommand. More...

#include <IntHistoryCommandTest.hxx>

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

Protected Member Functions

void SetUp () override
 Sets up the testing environment before each test.
void TearDown () override
 Tears down the testing environment after each test.
void createTestFile (const std::string &filename, const std::string &content) const
 Creates a test file with specified content in the temporary directory.
void createTestDirectory (const std::string &dirname) const
 Creates a test directory in the temporary location.
void stageFiles (const std::vector< std::string > &files) const
 Stages a list of files using the RepositoryManager's staging logic.
bool createTestCommit (const std::string &message)
 Creates a new commit (save) with a specified message.
int countMessages (const std::vector< Event > &notifications, const std::string &message)
 Counts the occurrences of a specific message (substring) across all event notifications.

Static Protected Member Functions

static bool containsMessage (const std::vector< Event > &notifications, const std::string &message)
 Checks if a specific message (substring) exists in any event notification.

Protected Attributes

std::shared_ptr< MockSubjectmockEventBus
 Shared pointer to the mock event bus (observer).
std::shared_ptr< RepositoryManagerrepoManager
 Shared pointer to the repository core logic component.
std::unique_ptr< HistoryCommandcommand
 Unique pointer to the command being tested.
std::filesystem::path testDir
 Path to the temporary test repository directory.

Detailed Description

Google Test fixture for running integration tests against the HistoryCommand.

This fixture provides the necessary infrastructure for integration tests of the history command:

  • SetUp/TearDown: Manage a temporary SVCS repository directory.
  • Core Components: Instances of MockSubject (for event bus) and RepositoryManager (for core logic).
  • Helper Methods: Simplify file creation, staging, and crucially, creating mock commits to populate the history for testing various output formats and limits.

Member Function Documentation

◆ containsMessage()

bool svcs::test::cli::utils::HistoryCommandTest::containsMessage ( const std::vector< Event > & notifications,
const std::string & message )
staticprotected

Checks if a specific message (substring) exists in any event notification.

Parameters
notificationsThe list of captured events.
messageThe substring to search for.
Returns
true if the message is found, false otherwise.

◆ countMessages()

int svcs::test::cli::utils::HistoryCommandTest::countMessages ( const std::vector< Event > & notifications,
const std::string & message )
protected

Counts the occurrences of a specific message (substring) across all event notifications.

Parameters
notificationsThe list of captured events.
messageThe substring to count.
Returns
The number of events containing the substring.

◆ createTestCommit()

bool svcs::test::cli::utils::HistoryCommandTest::createTestCommit ( const std::string & message)
protected

Creates a new commit (save) with a specified message.

Internally stages files (if needed) and calls the repository manager's commit logic.

Parameters
messageThe commit message.
Returns
true if the commit was successful, false otherwise.

◆ createTestDirectory()

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

Creates a test directory in the temporary location.

Parameters
dirnameThe relative path/name of the directory.

◆ createTestFile()

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

Creates a test file with specified content in the temporary directory.

Parameters
filenameThe relative path/name of the file.
contentThe content to write to the file.

◆ SetUp()

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

Sets up the testing environment before each test.

Initializes components, creates the temporary directory, and initializes the repository.

◆ stageFiles()

void svcs::test::cli::utils::HistoryCommandTest::stageFiles ( const std::vector< std::string > & files) const
protected

Stages a list of files using the RepositoryManager's staging logic.

Parameters
filesA vector of file names to stage.

◆ TearDown()

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

Tears down the testing environment after each test.

Cleans up the temporary directory and restores the working path.


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