MCPcopy Index your code
hub / github.com/AI45Lab/Code / test_llm_cost_record_serialize

Function test_llm_cost_record_serialize

core/src/telemetry.rs:495–516  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

493
494 #[test]
495 fn test_llm_cost_record_serialize() {
496 let record = LlmCostRecord {
497 model: "claude-sonnet-4-20250514".to_string(),
498 provider: "anthropic".to_string(),
499 prompt_tokens: 1000,
500 completion_tokens: 500,
501 total_tokens: 1500,
502 cost_usd: Some(0.0105),
503 timestamp: chrono::Utc::now(),
504 session_id: Some("sess-123".to_string()),
505 };
506
507 let json = serde_json::to_string(&record).unwrap();
508 assert!(json.contains("claude-sonnet-4-20250514"));
509 assert!(json.contains("anthropic"));
510 assert!(json.contains("1000"));
511
512 // Deserialize back
513 let deserialized: LlmCostRecord = serde_json::from_str(&json).unwrap();
514 assert_eq!(deserialized.model, "claude-sonnet-4-20250514");
515 assert_eq!(deserialized.prompt_tokens, 1000);
516 }
517
518 #[test]
519 fn test_timed_span_elapsed() {

Callers

nothing calls this directly

Calls 1

nowFunction · 0.85

Tested by

no test coverage detected