test(infrastructure): write RelayLabelRepository trait tests

Add reusable test suite with 18 test functions covering get_label(),
save_label(), delete_label(), and get_all_labels() methods. Tests
verify contract compliance for any repository implementation.

Added delete_label() method to trait interface and implemented it in
MockRelayLabelRepository to support complete CRUD operations.

TDD phase: RED - Tests written before SQLite implementation (T036)

Ref: T035 (specs/001-modbus-relay-control/tasks.md)
This commit is contained in:
2026-01-11 00:59:58 +01:00
parent 306fa38935
commit 982baec8a2
5 changed files with 405 additions and 1 deletions

View File

@@ -29,6 +29,15 @@ pub trait RelayLabelRepository: Send + Sync {
/// Returns `RepositoryError::DatabaseError` if the database operation fails.
async fn save_label(&self, id: RelayId, label: RelayLabel) -> Result<(), RepositoryError>;
/// Deletes the label for a specific relay.
///
/// If no label exists for the relay, this operation succeeds without error.
///
/// # Errors
///
/// Returns `RepositoryError::DatabaseError` if the database operation fails.
async fn delete_label(&self, id: RelayId) -> Result<(), RepositoryError>;
/// Retrieves all relay labels from the repository.
///
/// Returns a vector of tuples containing relay IDs and their corresponding labels.