SVCS - English Documentation
Loading...
Searching...
No Matches
IntHistoryCommandTest.hxx
Go to the documentation of this file.
1
21
22#pragma once
23
24#include <gtest/gtest.h>
25#include <memory>
26#include <vector>
27#include <string>
28#include <filesystem>
29
32
48namespace svcs::test::cli::utils {
49
50using svcs::services::Event;
51using svcs::core::RepositoryManager;
52using svcs::cli::HistoryCommand;
54
78class HistoryCommandTest : public ::testing::Test {
79protected:
89 void SetUp() override;
90
100 void TearDown() override;
101
113 void createTestFile(const std::string& filename, const std::string& content) const;
114
124 void createTestDirectory(const std::string& dirname) const;
125
135 void stageFiles(const std::vector<std::string>& files) const;
136
142
150 bool createTestCommit(const std::string& message);
151
165 static bool containsMessage(const std::vector<Event>& notifications, const std::string& message);
166
180 int countMessages(const std::vector<Event>& notifications, const std::string& message);
181
189 std::shared_ptr<MockSubject> mockEventBus;
190
198 std::shared_ptr<RepositoryManager> repoManager;
199
207 std::unique_ptr<HistoryCommand> command;
208
216 std::filesystem::path testDir;
217};
218
219}
Declaration of the HistoryCommand class for viewing save history (commits).
A mock implementation of ISubject for testing event-driven components.
Definition MockSubject.hxx:43
Google Test fixture for running integration tests against the HistoryCommand.
Definition IntHistoryCommandTest.hxx:53
void createTestDirectory(const std::string &dirname) const
Creates a test directory in the temporary location.
Definition IntHistoryCommandTest.cxx:55
std::shared_ptr< RepositoryManager > repoManager
Shared pointer to the repository core logic component.
Definition IntHistoryCommandTest.hxx:128
bool createTestCommit(const std::string &message)
Creates a new commit (save) with a specified message.
Definition IntHistoryCommandTest.cxx:65
void SetUp() override
Sets up the testing environment before each test.
Definition IntHistoryCommandTest.cxx:22
std::shared_ptr< MockSubject > mockEventBus
Shared pointer to the mock event bus (observer).
Definition IntHistoryCommandTest.hxx:122
void stageFiles(const std::vector< std::string > &files) const
Stages a list of files using the RepositoryManager's staging logic.
Definition IntHistoryCommandTest.cxx:59
std::unique_ptr< HistoryCommand > command
Unique pointer to the command being tested.
Definition IntHistoryCommandTest.hxx:134
static bool containsMessage(const std::vector< Event > &notifications, const std::string &message)
Checks if a specific message (substring) exists in any event notification.
Definition IntHistoryCommandTest.cxx:70
void createTestFile(const std::string &filename, const std::string &content) const
Creates a test file with specified content in the temporary directory.
Definition IntHistoryCommandTest.cxx:49
int countMessages(const std::vector< Event > &notifications, const std::string &message)
Counts the occurrences of a specific message (substring) across all event notifications.
Definition IntHistoryCommandTest.cxx:78
void TearDown() override
Tears down the testing environment after each test.
Definition IntHistoryCommandTest.cxx:43
std::filesystem::path testDir
Path to the temporary test repository directory.
Definition IntHistoryCommandTest.hxx:140
Mock implementation of the ISubject interface for unit testing purposes.
Utility classes and test fixtures for CLI command testing.
Definition ClearCommandTest.cxx:17