TestExtractJSONMetricsIntegration tests the integration between different metric extraction functions
(t *testing.T)
| 518 | |
| 519 | // TestExtractJSONMetricsIntegration tests the integration between different metric extraction functions |
| 520 | func TestExtractJSONMetricsIntegration(t *testing.T) { |
| 521 | // Test with realistic Claude API response |
| 522 | claudeResponse := map[string]any{ |
| 523 | "id": "msg_01ABC123", |
| 524 | "type": "message", |
| 525 | "role": "assistant", |
| 526 | "content": []any{ |
| 527 | map[string]any{ |
| 528 | "type": "text", |
| 529 | "text": "Hello, world!", |
| 530 | }, |
| 531 | }, |
| 532 | "model": "claude-3-5-sonnet-20241022", |
| 533 | "stop_reason": "end_turn", |
| 534 | "stop_sequence": nil, |
| 535 | "usage": map[string]any{ |
| 536 | "input_tokens": 25, |
| 537 | "output_tokens": 5, |
| 538 | }, |
| 539 | } |
| 540 | |
| 541 | jsonBytes, err := json.Marshal(claudeResponse) |
| 542 | if err != nil { |
| 543 | t.Fatalf("Failed to marshal test data: %v", err) |
| 544 | } |
| 545 | |
| 546 | metrics := ExtractJSONMetrics(string(jsonBytes), false) |
| 547 | |
| 548 | if metrics.TokenUsage != 30 { |
| 549 | t.Errorf("Expected token usage 30, got %d", metrics.TokenUsage) |
| 550 | } |
| 551 | |
| 552 | if metrics.EstimatedCost != 0.0 { |
| 553 | t.Errorf("Expected no cost information, got %f", metrics.EstimatedCost) |
| 554 | } |
| 555 | } |
| 556 | |
| 557 | func TestPrettifyToolName(t *testing.T) { |
| 558 | tests := []struct { |
nothing calls this directly
no test coverage detected