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

Function TestComputeFirewallDiff_VolumeChanges

pkg/cli/audit_diff_test.go:152–176  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

150}
151
152func 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
178func TestComputeFirewallDiff_BothNil(t *testing.T) {
179 diff := computeFirewallDiff(100, 200, nil, nil)

Callers

nothing calls this directly

Calls 1

computeFirewallDiffFunction · 0.85

Tested by

no test coverage detected