This is an automated email from the ASF dual-hosted git repository.
yangyang pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/dubbo-rust.git
The following commit(s) were added to refs/heads/main by this push:
new d2cb383 fix logical error of get_protocol_or_default (#137)
d2cb383 is described below
commit d2cb3831e5d37132a9963a04891643e6089796b8
Author: G-XD <[email protected]>
AuthorDate: Tue May 16 21:26:17 2023 +0800
fix logical error of get_protocol_or_default (#137)
Co-authored-by: GXD <[email protected]>
---
config/src/protocol.rs | 20 ++++++++++++++++++--
1 file changed, 18 insertions(+), 2 deletions(-)
diff --git a/config/src/protocol.rs b/config/src/protocol.rs
index 86ff053..e2340c1 100644
--- a/config/src/protocol.rs
+++ b/config/src/protocol.rs
@@ -77,10 +77,26 @@ impl ProtocolRetrieve for ProtocolConfig {
} else {
let result = self.get_protocol(protocol_key);
if let Some(..) = result {
- panic!("default triple base dose not defined.")
- } else {
result.unwrap()
+ } else {
+ panic!("default triple base dose not defined.")
}
}
}
}
+
+#[cfg(test)]
+mod tests {
+
+ use super::{ProtocolConfig, ProtocolRetrieve};
+
+ #[test]
+ #[should_panic(expected = "default triple base dose not defined")]
+ pub fn test_get_invalid_protocol() {
+ let config = ProtocolConfig::default();
+
+ let _ = config.get_protocol_or_default("");
+
+ ()
+ }
+}