style: switch rustfmt to hard tabs; document tests-separate rule in TODO
- rustfmt.toml: hard_tabs = true; whole tree reformatted (no logic changes) - TODO §0.7: tests live in tests/, never inline #[cfg(test)] in code files (legacy inline tests to be migrated, see Backlog) - TODO: add backlog item for the inline-test migration
This commit is contained in:
parent
d8393e0f39
commit
18a0ffa53d
96 changed files with 6542 additions and 6537 deletions
|
|
@ -7,32 +7,32 @@ use tokio::net::TcpStream;
|
|||
struct NoopHandler;
|
||||
|
||||
impl ProtocolHandler for NoopHandler {
|
||||
fn name(&self) -> &'static str {
|
||||
"noop"
|
||||
}
|
||||
fn name(&self) -> &'static str {
|
||||
"noop"
|
||||
}
|
||||
|
||||
fn handshake<'a>(
|
||||
&'a self,
|
||||
_stream: &'a mut TcpStream,
|
||||
) -> Pin<Box<dyn Future<Output = anyhow::Result<HandshakeResult>> + Send + 'a>> {
|
||||
Box::pin(async { Ok(HandshakeResult::new(Upstream::new("127.0.0.1:9000"))) })
|
||||
}
|
||||
fn handshake<'a>(
|
||||
&'a self,
|
||||
_stream: &'a mut TcpStream,
|
||||
) -> Pin<Box<dyn Future<Output = anyhow::Result<HandshakeResult>> + Send + 'a>> {
|
||||
Box::pin(async { Ok(HandshakeResult::new(Upstream::new("127.0.0.1:9000"))) })
|
||||
}
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn empty_registry_reports_missing_protocols() {
|
||||
let registry = ProtocolRegistry::new();
|
||||
assert!(registry.is_empty());
|
||||
let err = registry.primary().err().expect("empty registry must fail fast");
|
||||
assert!(err.to_string().contains("no protocol plugins compiled"));
|
||||
let registry = ProtocolRegistry::new();
|
||||
assert!(registry.is_empty());
|
||||
let err = registry.primary().err().expect("empty registry must fail fast");
|
||||
assert!(err.to_string().contains("no protocol plugins compiled"));
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn registered_handler_resolves_by_name() {
|
||||
let mut registry = ProtocolRegistry::new();
|
||||
registry.register(Box::new(NoopHandler));
|
||||
let mut registry = ProtocolRegistry::new();
|
||||
registry.register(Box::new(NoopHandler));
|
||||
|
||||
assert_eq!(registry.names(), vec!["noop"]);
|
||||
let handler = registry.primary().expect("registered handler must resolve");
|
||||
assert_eq!(handler.name(), "noop");
|
||||
assert_eq!(registry.names(), vec!["noop"]);
|
||||
let handler = registry.primary().expect("registered handler must resolve");
|
||||
assert_eq!(handler.name(), "noop");
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue