fix(domain): drop unwrap/panic from command tests for clippy gate
The workspace lints deny `clippy::unwrap_used` and `clippy::panic`, but `command.rs`'s two unit tests used `.unwrap()` and `panic!`, so `cargo clippy --workspace --all-targets -- -D warnings` (a CI gate) failed on them. Convert both to the crate's Result-returning test convention: `CommandIntent::parse(...)?` instead of `.unwrap()`, and a `return Err(...)` in the let-else instead of `panic!`. Same assertions; `DomainError` is `thiserror::Error`, so `?` flows into `Box<dyn Error>`. Workspace clippy --all-targets now reports 0 errors. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -78,19 +78,21 @@ mod tests {
|
|||||||
use super::CommandIntent;
|
use super::CommandIntent;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn plain_text_parses_as_search() {
|
fn plain_text_parses_as_search() -> Result<(), Box<dyn std::error::Error>> {
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
CommandIntent::parse("servo browser").unwrap(),
|
CommandIntent::parse("servo browser")?,
|
||||||
CommandIntent::Search("servo browser".to_string())
|
CommandIntent::Search("servo browser".to_string())
|
||||||
);
|
);
|
||||||
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn domain_like_text_parses_as_navigation() {
|
fn domain_like_text_parses_as_navigation() -> Result<(), Box<dyn std::error::Error>> {
|
||||||
let intent = CommandIntent::parse("example.com").unwrap();
|
let intent = CommandIntent::parse("example.com")?;
|
||||||
let CommandIntent::Navigate(url) = intent else {
|
let CommandIntent::Navigate(url) = intent else {
|
||||||
panic!("expected navigation intent");
|
return Err("expected navigation intent".into());
|
||||||
};
|
};
|
||||||
assert_eq!(url.as_str(), "https://example.com");
|
assert_eq!(url.as_str(), "https://example.com");
|
||||||
|
Ok(())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user