use claude_runner_core::{ ClaudeCommand, InputFormat, OutputFormat };
fn args_of( cmd: &ClaudeCommand ) -> Vec<String> {
let c = cmd.build_command_for_test();
c.get_args().map( |a| a.to_string_lossy().to_string() ).collect()
}
#[test]
fn with_print_true_adds_p_flag() {
let cmd = ClaudeCommand::new().with_print( true );
assert!( args_of( &cmd ).contains( &"-p".to_string() ) );
}
#[test]
fn with_print_false_adds_nothing() {
let cmd = ClaudeCommand::new().with_print( false );
assert!( !args_of( &cmd ).contains( &"-p".to_string() ) );
}
#[test]
fn with_output_format_text_adds_flag() {
let cmd = ClaudeCommand::new().with_output_format( OutputFormat::Text );
let args = args_of( &cmd );
assert!( args.contains( &"--output-format".to_string() ) );
assert!( args.contains( &"text".to_string() ) );
}
#[test]
fn with_output_format_json_adds_flag() {
let cmd = ClaudeCommand::new().with_output_format( OutputFormat::Json );
let args = args_of( &cmd );
assert!( args.contains( &"--output-format".to_string() ) );
assert!( args.contains( &"json".to_string() ) );
}
#[test]
fn with_output_format_stream_json_uses_hyphen() {
let cmd = ClaudeCommand::new().with_output_format( OutputFormat::StreamJson );
let args = args_of( &cmd );
assert!( args.contains( &"--output-format".to_string() ) );
assert!( args.contains( &"stream-json".to_string() ), "must use hyphen: {args:?}" );
assert!( !args.contains( &"stream_json".to_string() ), "must NOT use underscore" );
}
#[test]
fn with_input_format_text_adds_flag() {
let cmd = ClaudeCommand::new().with_input_format( InputFormat::Text );
let args = args_of( &cmd );
assert!( args.contains( &"--input-format".to_string() ) );
assert!( args.contains( &"text".to_string() ) );
}
#[test]
fn with_input_format_stream_json_uses_hyphen() {
let cmd = ClaudeCommand::new().with_input_format( InputFormat::StreamJson );
let args = args_of( &cmd );
assert!( args.contains( &"--input-format".to_string() ) );
assert!( args.contains( &"stream-json".to_string() ), "must use hyphen: {args:?}" );
assert!( !args.contains( &"stream_json".to_string() ), "must NOT use underscore" );
}
#[test]
fn with_include_partial_messages_true_adds_flag() {
let cmd = ClaudeCommand::new().with_include_partial_messages( true );
assert!( args_of( &cmd ).contains( &"--include-partial-messages".to_string() ) );
}
#[test]
fn with_include_partial_messages_false_adds_nothing() {
let cmd = ClaudeCommand::new().with_include_partial_messages( false );
assert!( !args_of( &cmd ).contains( &"--include-partial-messages".to_string() ) );
}
#[test]
fn with_replay_user_messages_true_adds_flag() {
let cmd = ClaudeCommand::new().with_replay_user_messages( true );
assert!( args_of( &cmd ).contains( &"--replay-user-messages".to_string() ) );
}
#[test]
fn with_replay_user_messages_false_adds_nothing() {
let cmd = ClaudeCommand::new().with_replay_user_messages( false );
assert!( !args_of( &cmd ).contains( &"--replay-user-messages".to_string() ) );
}
#[test]
fn with_json_schema_adds_flag_and_value() {
let schema = r#"{"type":"object"}"#;
let cmd = ClaudeCommand::new().with_json_schema( schema );
let args = args_of( &cmd );
assert!( args.contains( &"--json-schema".to_string() ) );
assert!( args.contains( &schema.to_string() ) );
}
#[test]
fn with_json_schema_passes_value_verbatim() {
let schema = r#"{"type":"array","items":{"type":"string"}}"#;
let cmd = ClaudeCommand::new().with_json_schema( schema );
let args = args_of( &cmd );
assert!( args.contains( &schema.to_string() ), "schema must be passed verbatim: {args:?}" );
}