use std::io::Cursor; use clap::Parser; use super::{Command, CommandLine, resolve_ticket, resolve_ticket_from}; #[test] fn parses_explicit_legacy_tag_cleanup() { let command_line = CommandLine::try_parse_from(["appa", "doctor", "--drop-legacy-tags", "--json"]) .expect("command should parse"); assert!(matches!( command_line.command, Command::Doctor { json: true, drop_legacy_tags: true, } )); } #[test] fn rejects_the_misleading_gc_flag() { assert!(CommandLine::try_parse_from(["appa", "doctor", "--gc"]).is_err()); } #[test] fn rejects_ambiguous_ticket_input() { assert!(resolve_ticket(Some("appa://ticket".to_owned()), true).is_err()); } #[test] fn trims_ticket_read_from_standard_input() { let mut input = Cursor::new(" appa://ticket\n"); let ticket = resolve_ticket_from(None, true, &mut input).expect("ticket should parse"); assert_eq!(ticket, "appa://ticket"); }