(t *testing.T)
| 125 | } |
| 126 | |
| 127 | func 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: ` |
| 139 | Task iteration 1: Starting analysis |
| 140 | Executing tool: github |
| 141 | Task iteration 2: Processing results |
| 142 | Calling write tool |
| 143 | Task iteration 3: Finalizing |
| 144 | `, |
| 145 | expectedTurns: 3, |
| 146 | expectedTools: 2, |
| 147 | }, |
| 148 | { |
| 149 | name: "parses errors and warnings", |
| 150 | logContent: ` |
| 151 | 2024-01-15 10:00:00 INFO: Starting task |
| 152 | 2024-01-15 10:00:01 ERROR: Failed to connect to service |
| 153 | 2024-01-15 10:00:02 WARNING: Retry attempt 1 |
| 154 | 2024-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: ` |
| 161 | Calling: github_search |
| 162 | Tool call: write_file |
| 163 | Using tool: bash |
| 164 | Executing 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: ` |
| 180 | The agent tool calls a command which launches the unified process |
| 181 | Since the tool or alternative is needed, we use it |
| 182 | The tool calls for analysis |
| 183 | tool call to the API |
| 184 | The agent is making tool calls with certain parameters |
nothing calls this directly
no test coverage detected