Mock implementation of ObjectStorage.
More...
|
|
| MockObjectStorage (const fs::path &temp_dir) |
| bool | saveObject (const VcsObject &object) const override |
| | Saves a VcsObject to the object database.
|
| std::unique_ptr< VcsObject > | loadObject (const std::string &hash) const override |
| | Loads an object from the disk by its hash ID.
|
|
void | clear () |
|
bool | is_blob_saved (const std::string &hash) const |
|
size_t | get_saved_blobs_count () const |
| | ObjectStorage (const std::string &root_path, const std::shared_ptr< ISubject > &subject=nullptr) |
| | Constructor for ObjectStorage.
|
|
virtual | ~ObjectStorage () |
| | Destructor.
|
| void | setSubject (std::shared_ptr< ISubject > subj) |
| | Sets or replaces the event subject used by the ObjectStorage.
|
| std::string | getObjectPath (const std::string &hash) const |
| | Forms the full filesystem path for an object based on its hash.
|
| bool | objectExists (const std::string &hash) const |
| | Checks if an object with the given hash exists on disk.
|
|
|
std::map< std::string, std::string > | saved_blobs |
Mock implementation of ObjectStorage.
- This mock substitutes the actual filesystem I/O for object saving and loading with an in-memory map, allowing for fast, isolated testing of the Index's interaction with the storage layer.
◆ loadObject()
| std::unique_ptr< VcsObject > svcs::test::core::MockObjectStorage::loadObject |
( |
const std::string & | hash | ) |
const |
|
inlineoverridevirtual |
Loads an object from the disk by its hash ID.
Reads the compressed file, decompresses it, performs integrity checks, and deserializes the object using the internal factory method.
- Parameters
-
| hash | The hash ID of the object to load. |
- Returns
- std::unique_ptr<VcsObject> The restored object instance.
- Exceptions
-
| std::runtime_error | if the object is not found, corrupted, or invalid. |
Reimplemented from svcs::core::ObjectStorage.
◆ saveObject()
| bool svcs::test::core::MockObjectStorage::saveObject |
( |
const VcsObject & | obj | ) |
const |
|
inlineoverridevirtual |
Saves a VcsObject to the object database.
Serializes the object, prefixes it with a header, compresses it, and writes it to a file. Publishes events on success/failure.
- Parameters
-
- Returns
- bool True if saving was successful.
- Exceptions
-
| std::runtime_error | if hash is invalid or file IO fails. |
Reimplemented from svcs::core::ObjectStorage.
The documentation for this class was generated from the following file: