claude-connector: rustfmt and clippy on the readiness tests
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
2f2f7a9db5
commit
85ed36d292
4 changed files with 56 additions and 24 deletions
|
|
@ -1391,7 +1391,11 @@ fn a_port_that_cannot_spawn_is_a_provider_failure() {
|
|||
let result = backend.execute(claim.call());
|
||||
let (kind, message, usage) = failure_of(&result);
|
||||
assert_eq!(kind, FailureKind::Provider);
|
||||
assert_eq!(usage, Some(usage_zero()), "a child that never ran bills nothing");
|
||||
assert_eq!(
|
||||
usage,
|
||||
Some(usage_zero()),
|
||||
"a child that never ran bills nothing"
|
||||
);
|
||||
assert_eq!(parts(&result).1.cost_micro_usd, 0);
|
||||
assert!(
|
||||
!message.contains(dir.path().to_str().unwrap()),
|
||||
|
|
@ -1664,7 +1668,11 @@ fn pin_is_checked_before_every_spawn() {
|
|||
let result = rig.run(request(vec![user("hi")]));
|
||||
let (kind, message, usage) = failure_of(&result);
|
||||
assert_eq!((kind, usage), (FailureKind::Provider, Some(usage_zero())));
|
||||
assert_eq!(parts(&result).1.cost_micro_usd, 0, "billed nothing, not the reservation");
|
||||
assert_eq!(
|
||||
parts(&result).1.cost_micro_usd,
|
||||
0,
|
||||
"billed nothing, not the reservation"
|
||||
);
|
||||
assert!(!message.contains(rig.dir.path().to_str().unwrap()));
|
||||
assert_eq!(rig.spawns(), 1, "no child for a binary off its pin");
|
||||
assert!(!rig.backend.binary_matches_pin());
|
||||
|
|
|
|||
|
|
@ -267,17 +267,20 @@ fn is_canonical_model(model: &str) -> bool {
|
|||
/// lets a call cost nothing against the caller's ceiling.
|
||||
fn is_fully_priced(price: &ModelPrice) -> bool {
|
||||
let long = price.long_context.map(|long| long.rates);
|
||||
[Some(price.rates), long].into_iter().flatten().all(|rates| {
|
||||
[
|
||||
rates.input,
|
||||
rates.cache_write_short,
|
||||
rates.cache_write_long,
|
||||
rates.cache_read,
|
||||
rates.output,
|
||||
]
|
||||
.iter()
|
||||
.all(|rate| *rate > 0)
|
||||
})
|
||||
[Some(price.rates), long]
|
||||
.into_iter()
|
||||
.flatten()
|
||||
.all(|rates| {
|
||||
[
|
||||
rates.input,
|
||||
rates.cache_write_short,
|
||||
rates.cache_write_long,
|
||||
rates.cache_read,
|
||||
rates.output,
|
||||
]
|
||||
.iter()
|
||||
.all(|rate| *rate > 0)
|
||||
})
|
||||
}
|
||||
|
||||
/// One file name under `$CREDENTIALS_DIRECTORY`, never a path.
|
||||
|
|
@ -438,8 +441,11 @@ mod tests {
|
|||
let sink = LogSink(Mutex::new(log.clone()));
|
||||
sink.stderr_tail(b"canary-stderr-text, 22 bytes");
|
||||
let written = String::from_utf8(log.0.lock().unwrap().clone()).unwrap();
|
||||
assert_eq!(written, "claude-connector: child stderr, 28 bytes
|
||||
");
|
||||
assert_eq!(
|
||||
written,
|
||||
"claude-connector: child stderr, 28 bytes
|
||||
"
|
||||
);
|
||||
assert!(!written.contains("canary"));
|
||||
}
|
||||
|
||||
|
|
@ -491,8 +497,8 @@ mod tests {
|
|||
fn a_link_to_a_good_directory_is_refused() {
|
||||
let dir = Dir::new("link-target");
|
||||
dir.mode(0o700);
|
||||
let link = std::env::temp_dir()
|
||||
.join(format!("claude-prompt-dir-{}-link", std::process::id()));
|
||||
let link =
|
||||
std::env::temp_dir().join(format!("claude-prompt-dir-{}-link", std::process::id()));
|
||||
let _ = std::fs::remove_file(&link);
|
||||
symlink(&dir.0, &link).unwrap();
|
||||
let refused = check_prompt_dir(&link).is_err();
|
||||
|
|
|
|||
|
|
@ -301,7 +301,8 @@ fn config_refuses_aliases_unpriced_models_and_second_callers() {
|
|||
"trailing part",
|
||||
Box::new(|c| {
|
||||
c.callers[0].allowed_models = vec!["claude-opus-5-1-20260101-x".to_string()];
|
||||
c.prices.insert("claude-opus-5-1-20260101-x".to_string(), price());
|
||||
c.prices
|
||||
.insert("claude-opus-5-1-20260101-x".to_string(), price());
|
||||
}),
|
||||
),
|
||||
(
|
||||
|
|
@ -364,7 +365,8 @@ fn a_dated_canonical_id_is_allowed() {
|
|||
|
||||
#[test]
|
||||
fn a_price_with_a_zero_billed_component_is_refused() {
|
||||
let zeroed: Vec<(&str, fn(&mut Rates))> = vec![
|
||||
type Zero = fn(&mut Rates);
|
||||
let zeroed: Vec<(&str, Zero)> = vec![
|
||||
("input", |r| r.input = 0),
|
||||
("cache_write_short", |r| r.cache_write_short = 0),
|
||||
("cache_write_long", |r| r.cache_write_long = 0),
|
||||
|
|
@ -644,7 +646,10 @@ fn prepare(scratch: &Scratch) -> (Vec<String>, PathBuf) {
|
|||
.map(|byte| format!("{byte:02x}"))
|
||||
.collect();
|
||||
let mut flags = init_flags(scratch, &[]);
|
||||
let at = flags.iter().position(|flag| flag == "--claude-sha256").unwrap();
|
||||
let at = flags
|
||||
.iter()
|
||||
.position(|flag| flag == "--claude-sha256")
|
||||
.unwrap();
|
||||
flags[at + 1] = sha;
|
||||
(flags, scratch.path("credentials"))
|
||||
}
|
||||
|
|
@ -734,7 +739,11 @@ fn check_refuses_exactly_what_serve_refuses_and_names_the_field() {
|
|||
let (checked, served) = check_and_serve(&scratch.path("connector.cc"), Some(&credentials));
|
||||
assert!(!checked.status.success(), "{name} check passed");
|
||||
assert!(!served.status.success(), "{name} serve started");
|
||||
assert!(shown(&checked).contains(field), "{name}: {}", shown(&checked));
|
||||
assert!(
|
||||
shown(&checked).contains(field),
|
||||
"{name}: {}",
|
||||
shown(&checked)
|
||||
);
|
||||
assert_eq!(shown(&checked), shown(&served), "{name}");
|
||||
for secret in [CANARY, "caller-secret", "other bytes"] {
|
||||
assert!(!shown(&checked).contains(secret), "{name}");
|
||||
|
|
@ -759,14 +768,20 @@ fn serve_names_a_corrupt_replay_store_without_its_path() {
|
|||
let store = scratch.path(&format!("{CANARY}-store/replay.cc"));
|
||||
std::fs::create_dir_all(store.parent().unwrap()).unwrap();
|
||||
std::fs::write(&store, b"not a cultcache store").unwrap();
|
||||
let at = flags.iter().position(|flag| flag == "--replay-store").unwrap();
|
||||
let at = flags
|
||||
.iter()
|
||||
.position(|flag| flag == "--replay-store")
|
||||
.unwrap();
|
||||
flags[at + 1] = store.to_string_lossy().into_owned();
|
||||
assert!(init(&scratch, &flags).status.success());
|
||||
let (_, served) = check_and_serve(&scratch.path("connector.cc"), Some(&credentials));
|
||||
assert!(!served.status.success());
|
||||
let text = shown(&served);
|
||||
assert!(text.contains("replay_store"), "{text}");
|
||||
assert!(!text.contains(CANARY) && !text.contains("replay.cc"), "{text}");
|
||||
assert!(
|
||||
!text.contains(CANARY) && !text.contains("replay.cc"),
|
||||
"{text}"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
|
|
|||
|
|
@ -709,7 +709,10 @@ mod tests {
|
|||
&store.path,
|
||||
backend.clone(),
|
||||
);
|
||||
assert!(matches!(result, Some(Err(ServeError::BackendUnready("fixture")))));
|
||||
assert!(matches!(
|
||||
result,
|
||||
Some(Err(ServeError::BackendUnready("fixture")))
|
||||
));
|
||||
assert_eq!(backend.executions.load(Ordering::SeqCst), 0);
|
||||
assert!(
|
||||
!store.path.exists(),
|
||||
|
|
|
|||
Loading…
Reference in a new issue