Files
imeai-aKode/akode-rs/otel/src/tool_result_tests.rs
andrea.difonzo 7c1c6dfa8d Rinomina: crate akode-*, cartelle akode-rs/ e akode-cli/, binario akode, ~/.akode, AKODE_* (A)
Riapplica la fase 5 di aKode (86e7c72e) sulla base ripulita:
- crate codex-* -> akode-*, codex-rs -> akode-rs, codex-cli -> akode-cli, binario e ausiliari akode;
- ~/.codex -> ~/.akode, CODEX_HOME -> AKODE_HOME, variabili CODEX_* -> AKODE_*, .codex/ -> .akode/ di progetto;
  nessun fallback a ~/.codex o a CODEX_*;
- testi per l'utente "Codex" -> "aKode"; testi verso il modello e istruzioni di sistema invariati;
- snapshot insta rinominati (non ancora rigenerati).
I conflitti con la base ripulita sono stati risolti riapplicando la rinomina ai file senza le
funzioni di imeAI (script di mappa dei token per file).

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-17 12:37:52 +01:00

68 lines
2.1 KiB
Rust

use super::*;
use pretty_assertions::assert_eq;
#[test]
fn telemetry_preview_returns_original_within_limits() {
// A literal marker in the tool's own output must not imply telemetry truncation.
for content in ["", "first\r\nsecond\r\n", TRUNCATION_NOTICE] {
let preview = telemetry_preview(content, ToolResultLogConfig::default());
assert!(matches!(preview.text, Cow::Borrowed(_)));
assert_eq!(
preview,
ToolResultPreview {
text: Cow::Borrowed(content),
truncated: false
}
);
}
}
#[test]
fn telemetry_preview_truncates_by_bytes() {
let limits = ToolResultLogConfig::default();
let content = "x".repeat(limits.max_bytes + 8);
let preview = telemetry_preview(&content, limits);
assert!(preview.truncated);
assert!(preview.text.contains(TRUNCATION_NOTICE));
assert!(preview.text.len() <= limits.max_bytes + TRUNCATION_NOTICE.len() + 1);
assert_eq!(
telemetry_preview(
&content,
ToolResultLogConfig {
max_bytes: content.len(),
}
),
ToolResultPreview {
text: Cow::Borrowed(&content),
truncated: false
}
);
assert_eq!(
telemetry_preview("éé", ToolResultLogConfig { max_bytes: 3 }),
ToolResultPreview {
text: Cow::Owned(format!("é\n{TRUNCATION_NOTICE}")),
truncated: true
}
);
for (content, max_bytes, expected, truncated) in [
("", 0, "".to_string(), false),
("\nsecret", 0, TRUNCATION_NOTICE.to_string(), true),
(
"first\r\nsecond",
7,
format!("first\r\n{TRUNCATION_NOTICE}"),
true,
),
("first\r\n", 7, "first\r\n".to_string(), false),
("\n\nsecret", 1, format!("\n{TRUNCATION_NOTICE}"), true),
] {
assert_eq!(
telemetry_preview(content, ToolResultLogConfig { max_bytes }),
ToolResultPreview {
text: Cow::Owned(expected),
truncated
}
);
}
}