(t *testing.T)
| 150 | } |
| 151 | |
| 152 | func TestComputeFirewallDiff_VolumeChanges(t *testing.T) { |
| 153 | run1 := &FirewallAnalysis{ |
| 154 | RequestsByDomain: map[string]DomainRequestStats{ |
| 155 | "api.github.com:443": {Allowed: 23, Blocked: 0}, |
| 156 | "cdn.example.com:443": {Allowed: 50, Blocked: 0}, |
| 157 | }, |
| 158 | } |
| 159 | run2 := &FirewallAnalysis{ |
| 160 | RequestsByDomain: map[string]DomainRequestStats{ |
| 161 | "api.github.com:443": {Allowed: 89, Blocked: 0}, |
| 162 | "cdn.example.com:443": {Allowed: 55, Blocked: 0}, |
| 163 | }, |
| 164 | } |
| 165 | |
| 166 | diff := computeFirewallDiff(100, 200, run1, run2) |
| 167 | |
| 168 | // api.github.com: 23 → 89 = +287% (over 100% threshold) |
| 169 | assert.Len(t, diff.VolumeChanges, 1, "Should have 1 volume change (api.github.com, not cdn)") |
| 170 | assert.Equal(t, "api.github.com:443", diff.VolumeChanges[0].Domain, "Volume change should be for api.github.com") |
| 171 | assert.Equal(t, "+287%", diff.VolumeChanges[0].VolumeChange, "Volume change should be +287%") |
| 172 | |
| 173 | // cdn.example.com: 50 → 55 = +10% (under threshold, not flagged) |
| 174 | assert.Equal(t, 1, diff.Summary.VolumeChangeCount, "Summary should show 1 volume change") |
| 175 | assert.False(t, diff.Summary.HasAnomalies, "Volume changes alone should not create anomalies") |
| 176 | } |
| 177 | |
| 178 | func TestComputeFirewallDiff_BothNil(t *testing.T) { |
| 179 | diff := computeFirewallDiff(100, 200, nil, nil) |
nothing calls this directly
no test coverage detected