(t *testing.T)
| 1082 | } |
| 1083 | |
| 1084 | func TestComputeToolCallsDiff_DuplicateToolNames(t *testing.T) { |
| 1085 | // When the same tool name appears multiple times (e.g. metrics aggregated from multiple log files), |
| 1086 | // call counts should be summed and max sizes kept. |
| 1087 | m1 := &LogMetrics{ |
| 1088 | ToolCalls: []ToolCallInfo{ |
| 1089 | {Name: "bash", CallCount: 3, MaxInputSize: 100, MaxOutputSize: 200}, |
| 1090 | {Name: "bash", CallCount: 4, MaxInputSize: 150, MaxOutputSize: 180}, |
| 1091 | }, |
| 1092 | } |
| 1093 | m2 := &LogMetrics{ |
| 1094 | ToolCalls: []ToolCallInfo{ |
| 1095 | {Name: "bash", CallCount: 5, MaxInputSize: 120, MaxOutputSize: 300}, |
| 1096 | {Name: "bash", CallCount: 2, MaxInputSize: 90, MaxOutputSize: 250}, |
| 1097 | }, |
| 1098 | } |
| 1099 | |
| 1100 | diff := computeToolCallsDiff(m1, m2) |
| 1101 | require.NotNil(t, diff, "Should produce diff") |
| 1102 | |
| 1103 | require.Len(t, diff.AllTools, 1, "Should have 1 unique tool (bash)") |
| 1104 | bash := diff.AllTools[0] |
| 1105 | assert.Equal(t, "bash", bash.Name, "Tool should be bash") |
| 1106 | // Run1: 3+4=7, Run2: 5+2=7 → unchanged |
| 1107 | assert.Equal(t, 7, bash.Run1CallCount, "Run1 call count should be sum: 3+4=7") |
| 1108 | assert.Equal(t, 7, bash.Run2CallCount, "Run2 call count should be sum: 5+2=7") |
| 1109 | assert.Equal(t, "unchanged", bash.Status, "Status should be unchanged when counts are equal") |
| 1110 | // Max input: run1=max(100,150)=150, run2=max(120,90)=120 |
| 1111 | assert.Equal(t, 150, bash.Run1MaxInputSize, "Run1 max input should be max(100,150)=150") |
| 1112 | assert.Equal(t, 120, bash.Run2MaxInputSize, "Run2 max input should be max(120,90)=120") |
| 1113 | // Max output: run1=max(200,180)=200, run2=max(300,250)=300 |
| 1114 | assert.Equal(t, 200, bash.Run1MaxOutputSize, "Run1 max output should be max(200,180)=200") |
| 1115 | assert.Equal(t, 300, bash.Run2MaxOutputSize, "Run2 max output should be max(300,250)=300") |
| 1116 | } |
| 1117 | |
| 1118 | func TestComputeToolCallsDiff_NewTools(t *testing.T) { |
| 1119 | m1 := &LogMetrics{ |
nothing calls this directly
no test coverage detected