Skip to content

Commit 20842c2

Browse files
committed
Fixed broken tests
1 parent 08efa2d commit 20842c2

File tree

2 files changed

+20
-34
lines changed

2 files changed

+20
-34
lines changed

crates/chat-cli/src/cli/chat/cli/prompts.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ use crate::cli::chat::prompt_args::{
3737
has_args_placeholder,
3838
substitute_arguments,
3939
validate_placeholders,
40-
ArgumentError,
4140
};
4241
use crate::cli::chat::tool_manager::PromptBundle;
4342
use crate::cli::chat::{

crates/chat-cli/src/cli/chat/prompt_args.rs

Lines changed: 20 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ pub fn substitute_arguments(content: &str, arguments: &[String]) -> Result<(Stri
136136
};
137137

138138
// Then replace positional placeholders
139-
result = PLACEHOLDER_REGEX.replace_all(&result, |caps: &regex::Captures| {
139+
result = PLACEHOLDER_REGEX.replace_all(&result, |caps: &regex::Captures<'_>| {
140140
let position_str = &caps[1];
141141
let position: u8 = position_str.parse().unwrap(); // Safe because regex already validated
142142

@@ -160,11 +160,6 @@ pub fn count_arguments(content: &str) -> usize {
160160
}
161161
}
162162

163-
/// Gets the highest argument position used in content
164-
pub fn get_max_argument_position(content: &str) -> Option<u8> {
165-
validate_placeholders(content).ok()?.into_iter().max()
166-
}
167-
168163
/// Checks if content contains $ARGS or ${@} placeholder
169164
pub fn has_args_placeholder(content: &str) -> bool {
170165
content.contains("$ARGS") || content.contains("${@}")
@@ -177,31 +172,31 @@ mod tests {
177172
#[test]
178173
fn test_validate_placeholders_with_args() {
179174
// Valid $ARGS only
180-
assert_eq!(validate_placeholders("Hello $ARGS").unwrap(), vec![]);
175+
assert_eq!(validate_placeholders("Hello $ARGS").unwrap(), Vec::<u8>::new());
181176

182177
// Valid ${@} only
183-
assert_eq!(validate_placeholders("Hello ${@}").unwrap(), vec![]);
178+
assert_eq!(validate_placeholders("Hello ${@}").unwrap(), Vec::<u8>::new());
184179

185180
// Valid mixed placeholders with $ARGS
186-
assert_eq!(validate_placeholders("${1} and $ARGS").unwrap(), vec![1]);
181+
assert_eq!(validate_placeholders("${1} and $ARGS").unwrap(), vec![1u8]);
187182

188183
// Valid mixed placeholders with ${@}
189-
assert_eq!(validate_placeholders("${1} and ${@}").unwrap(), vec![1]);
184+
assert_eq!(validate_placeholders("${1} and ${@}").unwrap(), vec![1u8]);
190185

191186
// Valid multiple with $ARGS
192-
assert_eq!(validate_placeholders("${1} ${2} $ARGS").unwrap(), vec![1, 2]);
187+
assert_eq!(validate_placeholders("${1} ${2} $ARGS").unwrap(), vec![1u8, 2u8]);
193188

194189
// Valid multiple with ${@}
195-
assert_eq!(validate_placeholders("${1} ${2} ${@}").unwrap(), vec![1, 2]);
190+
assert_eq!(validate_placeholders("${1} ${2} ${@}").unwrap(), vec![1u8, 2u8]);
196191

197192
// Multiple $ARGS (should work)
198-
assert_eq!(validate_placeholders("$ARGS and $ARGS").unwrap(), vec![]);
193+
assert_eq!(validate_placeholders("$ARGS and $ARGS").unwrap(), Vec::<u8>::new());
199194

200195
// Multiple ${@} (should work)
201-
assert_eq!(validate_placeholders("${@} and ${@}").unwrap(), vec![]);
196+
assert_eq!(validate_placeholders("${@} and ${@}").unwrap(), Vec::<u8>::new());
202197

203198
// Mixed $ARGS and ${@}
204-
assert_eq!(validate_placeholders("$ARGS and ${@}").unwrap(), vec![]);
199+
assert_eq!(validate_placeholders("$ARGS and ${@}").unwrap(), Vec::<u8>::new());
205200
}
206201

207202
#[test]
@@ -288,22 +283,22 @@ mod tests {
288283
#[test]
289284
fn test_validate_placeholders_valid() {
290285
// Valid single placeholder
291-
assert_eq!(validate_placeholders("Hello ${1}").unwrap(), vec![1]);
286+
assert_eq!(validate_placeholders("Hello ${1}").unwrap(), vec![1u8]);
292287

293288
// Valid multiple placeholders
294-
assert_eq!(validate_placeholders("${1} and ${2}").unwrap(), vec![1, 2]);
289+
assert_eq!(validate_placeholders("${1} and ${2}").unwrap(), vec![1u8, 2u8]);
295290

296291
// Valid out-of-order placeholders
297-
assert_eq!(validate_placeholders("${3} ${1} ${2}").unwrap(), vec![1, 2, 3]);
292+
assert_eq!(validate_placeholders("${3} ${1} ${2}").unwrap(), vec![1u8, 2u8, 3u8]);
298293

299294
// Valid duplicate placeholders
300-
assert_eq!(validate_placeholders("${1} ${1} ${2}").unwrap(), vec![1, 2]);
295+
assert_eq!(validate_placeholders("${1} ${1} ${2}").unwrap(), vec![1u8, 2u8]);
301296

302297
// Valid max position
303-
assert_eq!(validate_placeholders("${10}").unwrap(), vec![10]);
298+
assert_eq!(validate_placeholders("${10}").unwrap(), vec![10u8]);
304299

305300
// No placeholders
306-
assert_eq!(validate_placeholders("No placeholders here").unwrap(), vec![]);
301+
assert_eq!(validate_placeholders("No placeholders here").unwrap(), Vec::<u8>::new());
307302
}
308303

309304
#[test]
@@ -317,11 +312,11 @@ mod tests {
317312
// Invalid leading zeros
318313
assert!(validate_placeholders("${01}").is_err());
319314

320-
// Invalid format with spaces
321-
assert!(validate_placeholders("${ 1 }").is_err());
315+
// Invalid format with spaces - should be ignored, not error
316+
assert!(validate_placeholders("${ 1 }").is_ok());
322317

323-
// Invalid format with letters
324-
assert!(validate_placeholders("${a}").is_err());
318+
// Invalid format with letters - should be ignored, not error
319+
assert!(validate_placeholders("${a}").is_ok());
325320
}
326321

327322
#[test]
@@ -393,12 +388,4 @@ mod tests {
393388
assert_eq!(count_arguments("${1} ${1} ${2}"), 2); // Duplicates count as one
394389
assert_eq!(count_arguments("${3} ${1}"), 2);
395390
}
396-
397-
#[test]
398-
fn test_get_max_argument_position() {
399-
assert_eq!(get_max_argument_position("No args"), None);
400-
assert_eq!(get_max_argument_position("${1}"), Some(1));
401-
assert_eq!(get_max_argument_position("${1} ${5} ${3}"), Some(5));
402-
assert_eq!(get_max_argument_position("${10}"), Some(10));
403-
}
404391
}

0 commit comments

Comments
 (0)