Skip to content

Commit

Permalink
feat(configurer/protocol) expose a test constructor for `ReloadConfig…
Browse files Browse the repository at this point in the history
…sRejected` (#151)

Co-authored-by: Alexander Stanovoy <[email protected]>
  • Loading branch information
alexstanovoy and Alexander Stanovoy authored Jan 23, 2025
1 parent 4773575 commit 0fb4410
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 1 deletion.
3 changes: 3 additions & 0 deletions elfo-configurer/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,6 @@ fxhash = "0.2.1"

[dev-dependencies]
serde_json = "1.0.94"

[features]
test-util = []
16 changes: 16 additions & 0 deletions elfo-configurer/src/protocol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,14 @@ pub struct ReloadConfigsRejected {
pub errors: Vec<ReloadConfigsError>,
}

impl ReloadConfigsRejected {
/// Creates a new reject.
#[cfg(feature = "test-util")]
pub fn new(errors: Vec<ReloadConfigsError>) -> Self {
Self { errors }
}
}

/// Contains a reason why some actor rejects the config.
#[message(part)]
#[non_exhaustive]
Expand All @@ -34,3 +42,11 @@ pub struct ReloadConfigsError {
/// The reason why the config is rejected.
pub reason: String,
}

impl ReloadConfigsError {
/// Creates a new error.
#[cfg(feature = "test-util")]
pub fn new(group: String, reason: String) -> Self {
Self { group, reason }
}
}
2 changes: 1 addition & 1 deletion elfo/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ workspace = true

[features]
full = ["elfo-configurer", "elfo-logger", "elfo-dumper", "elfo-telemeter", "elfo-pinger"]
test-util = ["elfo-test", "elfo-core/test-util"]
test-util = ["elfo-test", "elfo-core/test-util", "elfo-configurer/test-util"]
network = ["elfo-network"]
unstable = ["elfo-core/unstable", "elfo-telemeter/unstable", "elfo-test/unstable" ]
unstable-stuck-detection = ["elfo-core/unstable-stuck-detection"]
Expand Down

0 comments on commit 0fb4410

Please sign in to comment.