(t *testing.T)
| 13 | ) |
| 14 | |
| 15 | func TestParseLogFileWithoutAwInfo(t *testing.T) { |
| 16 | // Create a temporary log file |
| 17 | tmpDir := testutil.TempDir(t, "test-*") |
| 18 | logFile := filepath.Join(tmpDir, "test.log") |
| 19 | |
| 20 | logContent := `2024-01-15T10:30:00Z Starting workflow execution |
| 21 | 2024-01-15T10:30:15Z Claude API request initiated |
| 22 | 2024-01-15T10:30:45Z Input tokens: 1250 |
| 23 | 2024-01-15T10:30:45Z Output tokens: 850 |
| 24 | 2024-01-15T10:30:45Z Total tokens used: 2100 |
| 25 | 2024-01-15T10:30:45Z Cost: $0.025 |
| 26 | 2024-01-15T10:31:30Z Workflow completed successfully` |
| 27 | |
| 28 | err := os.WriteFile(logFile, []byte(logContent), 0644) |
| 29 | if err != nil { |
| 30 | t.Fatalf("Failed to create test log file: %v", err) |
| 31 | } |
| 32 | |
| 33 | // Test parseLogFileWithEngine without an engine (simulates no aw_info.json) |
| 34 | metrics, err := parseLogFileWithEngine(logFile, nil, false, false) |
| 35 | if err != nil { |
| 36 | t.Fatalf("parseLogFileWithEngine failed: %v", err) |
| 37 | } |
| 38 | |
| 39 | // Without aw_info.json, should return empty metrics |
| 40 | if metrics.TokenUsage != 0 { |
| 41 | t.Errorf("Expected token usage 0 (no aw_info.json), got %d", metrics.TokenUsage) |
| 42 | } |
| 43 | |
| 44 | // Check cost - should be 0 without engine-specific parsing |
| 45 | if metrics.EstimatedCost != 0 { |
| 46 | t.Errorf("Expected cost 0 (no aw_info.json), got %f", metrics.EstimatedCost) |
| 47 | } |
| 48 | |
| 49 | // Duration is no longer extracted from logs - using GitHub API timestamps instead |
| 50 | } |
| 51 | |
| 52 | func TestExtractJSONMetrics(t *testing.T) { |
| 53 | tests := []struct { |
nothing calls this directly
no test coverage detected