MCPcopy Create free account
hub / github.com/github/gh-aw / TestParseLogFileWithoutAwInfo

Function TestParseLogFileWithoutAwInfo

pkg/cli/logs_parsing_test.go:15–50  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

13)
14
15func 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
212024-01-15T10:30:15Z Claude API request initiated
222024-01-15T10:30:45Z Input tokens: 1250
232024-01-15T10:30:45Z Output tokens: 850
242024-01-15T10:30:45Z Total tokens used: 2100
252024-01-15T10:30:45Z Cost: $0.025
262024-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
52func TestExtractJSONMetrics(t *testing.T) {
53 tests := []struct {

Callers

nothing calls this directly

Calls 3

TempDirFunction · 0.92
parseLogFileWithEngineFunction · 0.85
ErrorfMethod · 0.45

Tested by

no test coverage detected