SVCS - English Documentation
Loading...
Searching...
No Matches
svcs::test::core::MockObjectStorage Class Reference

Mock implementation of ObjectStorage. More...

Inheritance diagram for svcs::test::core::MockObjectStorage:
svcs::core::ObjectStorage

Public Member Functions

 MockObjectStorage (const fs::path &temp_dir)
bool saveObject (const VcsObject &object) const override
 Saves a VcsObject to the object database.
std::unique_ptr< VcsObjectloadObject (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
Public Member Functions inherited from svcs::core::ObjectStorage
 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.

Public Attributes

std::map< std::string, std::string > saved_blobs

Detailed Description

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.

Member Function Documentation

◆ 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
hashThe hash ID of the object to load.
Returns
std::unique_ptr<VcsObject> The restored object instance.
Exceptions
std::runtime_errorif 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
objThe VcsObject to save.
Returns
bool True if saving was successful.
Exceptions
std::runtime_errorif hash is invalid or file IO fails.

Reimplemented from svcs::core::ObjectStorage.


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