#[allow(unused_imports)]
use super::*;
#[test]
fn bare_encoded_token_still_accepted_as_target() {
let cli = parse(&["csift", "list", "-a--claude-b"]).expect("encoded token parses");
match cli.command {
Command::List(a) => assert_eq!(a.paths[0].to_string_lossy(), "-a--claude-b"),
_ => panic!("expected list"),
}
}
#[test]
fn real_path_target_still_accepted() {
let cli = parse(&["csift", "list", "/Users/testuser/Projects/foo"]).expect("real path parses");
match cli.command {
Command::List(a) => {
assert_eq!(a.paths[0].to_string_lossy(), "/Users/testuser/Projects/foo")
}
_ => panic!("expected list"),
}
}
#[test]
fn parse_project_target_accepts_real_targets_rejects_double_dash() {
assert!(parse_project_target("-Users-testuser-Projects-foo").is_ok());
assert!(parse_project_target("/Users/testuser/Projects/foo").is_ok());
assert!(parse_project_target(".").is_ok());
assert!(parse_project_target("-a--claude-b").is_ok());
assert!(parse_project_target("C--Users-dev-proj").is_ok()); let err = parse_project_target("--by-fil").unwrap_err();
assert!(err.contains("unexpected argument"), "got: {err}");
assert!(err.contains("'@--by-fil'"), "routes the UNC escape: {err}");
assert!(parse_project_target("-singledash").is_ok());
}
#[test]
fn unknown_flag_is_rejected_not_swallowed_as_target() {
for argv in [
["csift", "files", "--by-fil"].as_slice(),
["csift", "verbatim", "--budgett"].as_slice(),
["csift", "list", "--by-fil"].as_slice(),
["csift", "agents", "--bogus"].as_slice(),
] {
let err = parse(argv).expect_err("unknown flag must error");
let msg = err.to_string();
assert!(
!msg.contains("no Claude Code project dir named"),
"must not mask as project-dir error for {argv:?}: {msg}"
);
}
}
#[test]
fn list_routes_at_uuid_and_bare_uuid_as_positional() {
let at = format!("@{SESS_UUID}");
let cli = parse(&["csift", "list", at.as_str()]).unwrap();
match cli.command {
Command::List(a) => {
assert_eq!(a.paths.len(), 1, "the @<uuid> token is a positional target");
assert_eq!(a.paths[0].to_string_lossy(), at);
}
_ => panic!("expected list"),
}
let cli = parse(&["csift", "list", SESS_UUID]).unwrap();
match cli.command {
Command::List(a) => {
assert_eq!(a.paths.len(), 1, "the bare uuid is a positional target");
assert_eq!(a.paths[0].to_string_lossy(), SESS_UUID);
}
_ => panic!("expected list"),
}
}
#[test]
fn removed_session_flag_no_longer_parses() {
let dead_flag = concat!("--", "session");
assert!(
parse(&["csift", "list", dead_flag, SESS_UUID]).is_err(),
"a bare --session token must not parse"
);
}