MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / resolve_subject_error

Function resolve_subject_error

atomic-cli/src/commands/workspace/grant.rs:457–469  ·  view source on GitHub ↗

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>)

Source from the content-addressed store, hash-verified

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

Calls

no outgoing calls