Prepare Gotcha 1.0 for release
This commit is contained in:
45
crates/cli/src/tests.rs
Normal file
45
crates/cli/src/tests.rs
Normal file
@@ -0,0 +1,45 @@
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn parses_server_selection_and_repository_scope() {
|
||||
let args = Args::parse(
|
||||
["--server", "work", "repo", "show"].map(str::to_owned),
|
||||
None,
|
||||
)
|
||||
.unwrap();
|
||||
let repository = RepositoryScope::parse("alice/project").unwrap();
|
||||
|
||||
assert_eq!(args.server.as_deref(), Some("work"));
|
||||
assert_eq!(args.command, ["repo", "show"]);
|
||||
assert_eq!(
|
||||
(repository.owner.as_str(), repository.repository.as_str()),
|
||||
("alice", "project")
|
||||
);
|
||||
assert_eq!(requested_help(&[]).unwrap(), Some(ROOT_HELP));
|
||||
assert_eq!(requested_help(&["repo".into()]).unwrap(), Some(REPO_HELP));
|
||||
assert!(
|
||||
requested_help(&["repo".into(), "show".into(), "--help".into()])
|
||||
.unwrap()
|
||||
.unwrap()
|
||||
.starts_with("Usage: gotcha repo show")
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn formats_bounded_aligned_tables_without_tabs() {
|
||||
let table = format_table(
|
||||
&[("INDEX", 8), ("STATE", 10), ("TITLE", 60)],
|
||||
&[vec![
|
||||
"22".into(),
|
||||
"open".into(),
|
||||
"A deliberately long issue title that must be shortened".into(),
|
||||
]],
|
||||
40,
|
||||
);
|
||||
|
||||
assert!(!table.contains('\t'));
|
||||
assert!(table.contains('…'));
|
||||
assert_eq!(table.lines().count(), 3);
|
||||
assert!(table.lines().all(|line| line.chars().count() <= 40));
|
||||
assert!(table.lines().next().unwrap().starts_with("INDEX STATE"));
|
||||
}
|
||||
Reference in New Issue
Block a user