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

Function TestParseCopilotCodingAgentLogMetrics

pkg/cli/copilot_agent_test.go:127–235  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

125}
126
127func TestParseCopilotCodingAgentLogMetrics(t *testing.T) {
128 tests := []struct {
129 name string
130 logContent string
131 expectedTurns int
132 expectedErrors int
133 expectedTools int
134 expectNoTools bool // true when the test asserts that zero tool calls are extracted
135 }{
136 {
137 name: "parses agent turns",
138 logContent: `
139Task iteration 1: Starting analysis
140Executing tool: github
141Task iteration 2: Processing results
142Calling write tool
143Task iteration 3: Finalizing
144`,
145 expectedTurns: 3,
146 expectedTools: 2,
147 },
148 {
149 name: "parses errors and warnings",
150 logContent: `
1512024-01-15 10:00:00 INFO: Starting task
1522024-01-15 10:00:01 ERROR: Failed to connect to service
1532024-01-15 10:00:02 WARNING: Retry attempt 1
1542024-01-15 10:00:03 ERROR: Connection timeout
155`,
156 expectedErrors: 3, // 2 errors + 1 warning
157 },
158 {
159 name: "parses tool calls",
160 logContent: `
161Calling: github_search
162Tool call: write_file
163Using tool: bash
164Executing tool: read
165`,
166 expectedTools: 4,
167 },
168 {
169 name: "extracts tool from bullet point format",
170 logContent: `
171● startHttpServer
172● noop
173● label_agent
174`,
175 expectedTools: 3,
176 },
177 {
178 name: "does not extract common English words as tool names",
179 logContent: `
180The agent tool calls a command which launches the unified process
181Since the tool or alternative is needed, we use it
182The tool calls for analysis
183tool call to the API
184The agent is making tool calls with certain parameters

Callers

nothing calls this directly

Calls 3

RunMethod · 0.45
ErrorfMethod · 0.45

Tested by

no test coverage detected