(t *testing.T)
| 117 | } |
| 118 | |
| 119 | func TestParseLogFileWithJSON(t *testing.T) { |
| 120 | // Create a temporary log file with mixed JSON and text format |
| 121 | tmpDir := testutil.TempDir(t, "test-*") |
| 122 | logFile := filepath.Join(tmpDir, "test-mixed.log") |
| 123 | |
| 124 | logContent := `2024-01-15T10:30:00Z Starting workflow execution |
| 125 | {"type": "message_start"} |
| 126 | {"type": "content_block_delta", "delta": {"type": "text", "text": "Hello"}} |
| 127 | {"type": "message_delta", "delta": {"usage": {"input_tokens": 150, "output_tokens": 200}}} |
| 128 | Regular log line: tokens: 1000 |
| 129 | {"cost": 0.035} |
| 130 | 2024-01-15T10:31:30Z Workflow completed successfully` |
| 131 | |
| 132 | err := os.WriteFile(logFile, []byte(logContent), 0644) |
| 133 | if err != nil { |
| 134 | t.Fatalf("Failed to create test log file: %v", err) |
| 135 | } |
| 136 | |
| 137 | metrics, err := parseLogFileWithEngine(logFile, nil, false, false) |
| 138 | if err != nil { |
| 139 | t.Fatalf("parseLogFileWithEngine failed: %v", err) |
| 140 | } |
| 141 | |
| 142 | // Without aw_info.json and specific engine, should return empty metrics |
| 143 | if metrics.TokenUsage != 0 { |
| 144 | t.Errorf("Expected token usage 0 (no aw_info.json), got %d", metrics.TokenUsage) |
| 145 | } |
| 146 | |
| 147 | // Should have no cost without engine-specific parsing |
| 148 | if metrics.EstimatedCost != 0 { |
| 149 | t.Errorf("Expected cost 0 (no aw_info.json), got %f", metrics.EstimatedCost) |
| 150 | } |
| 151 | |
| 152 | // Duration is no longer extracted from logs - using GitHub API timestamps instead |
| 153 | } |
| 154 | |
| 155 | func TestConvertToInt(t *testing.T) { |
| 156 | tests := []struct { |
nothing calls this directly
no test coverage detected