(t *testing.T)
| 369 | } |
| 370 | |
| 371 | func TestComputeMCPToolsDiff_NewTools(t *testing.T) { |
| 372 | run1 := &MCPToolUsageData{ |
| 373 | Summary: []MCPToolSummary{ |
| 374 | {ServerName: "github", ToolName: "issue_read", CallCount: 5, ErrorCount: 0}, |
| 375 | }, |
| 376 | } |
| 377 | run2 := &MCPToolUsageData{ |
| 378 | Summary: []MCPToolSummary{ |
| 379 | {ServerName: "github", ToolName: "issue_read", CallCount: 5, ErrorCount: 0}, |
| 380 | {ServerName: "github", ToolName: "create_issue", CallCount: 3, ErrorCount: 0}, |
| 381 | {ServerName: "playwright", ToolName: "screenshot", CallCount: 2, ErrorCount: 1}, |
| 382 | }, |
| 383 | } |
| 384 | |
| 385 | diff := computeMCPToolsDiff(run1, run2) |
| 386 | |
| 387 | assert.Len(t, diff.NewTools, 2, "Should have 2 new tools") |
| 388 | assert.Empty(t, diff.RemovedTools, "Should have no removed tools") |
| 389 | assert.Empty(t, diff.ChangedTools, "Should have no changed tools") |
| 390 | |
| 391 | createIssue := findMCPToolDiffEntry(diff.NewTools, "github", "create_issue") |
| 392 | require.NotNil(t, createIssue, "Should find create_issue in new tools") |
| 393 | assert.Equal(t, "new", createIssue.Status, "Status should be 'new'") |
| 394 | assert.Equal(t, 3, createIssue.Run2CallCount, "Call count should be 3") |
| 395 | assert.False(t, createIssue.IsAnomaly, "No-error new tool should not be anomaly") |
| 396 | |
| 397 | screenshot := findMCPToolDiffEntry(diff.NewTools, "playwright", "screenshot") |
| 398 | require.NotNil(t, screenshot, "Should find screenshot in new tools") |
| 399 | assert.True(t, screenshot.IsAnomaly, "New tool with errors should be anomaly") |
| 400 | assert.Equal(t, "new tool with errors", screenshot.AnomalyNote, "Anomaly note should explain errors") |
| 401 | assert.Equal(t, 1, screenshot.Run2ErrorCount, "Error count should be 1") |
| 402 | |
| 403 | assert.Equal(t, 2, diff.Summary.NewToolCount, "Summary should show 2 new tools") |
| 404 | assert.True(t, diff.Summary.HasAnomalies, "Should have anomalies") |
| 405 | assert.Equal(t, 1, diff.Summary.AnomalyCount, "Should have 1 anomaly") |
| 406 | } |
| 407 | |
| 408 | func TestComputeMCPToolsDiff_RemovedTools(t *testing.T) { |
| 409 | run1 := &MCPToolUsageData{ |
nothing calls this directly
no test coverage detected