Extract the error message from resolve_subject's pure branches (those that don't touch the network). The team branch needs a client, so we only exercise the both/neither/invalid-UUID branches.
(team: Option<&str>, user: Option<&str>)
| 455 | /// that don't touch the network). The team branch needs a client, so we |
| 456 | /// only exercise the both/neither/invalid-UUID branches. |
| 457 | fn resolve_subject_error(team: Option<&str>, user: Option<&str>) -> String { |
| 458 | // We can't build a real StorageClient, so replicate the pure branches |
| 459 | // (both, neither, user UUID parse) which are the testable error paths. |
| 460 | match (team, user) { |
| 461 | (Some(_), Some(_)) => "Specify either --team or --user, not both.".to_string(), |
| 462 | (None, None) => "Specify --team <slug> or --user <uuid>.".to_string(), |
| 463 | (None, Some(id)) => match uuid::Uuid::parse_str(id) { |
| 464 | Ok(_) => "(would hit server)".to_string(), |
| 465 | Err(_) => format!("'{}' is not a valid UUID.", id), |
| 466 | }, |
| 467 | (Some(_), None) => "(would hit server)".to_string(), |
| 468 | } |
| 469 | } |
| 470 | |
| 471 | // -- subject_label -- |
| 472 |
no outgoing calls