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

Function TestFirewallDiffJSONSerialization

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

Source from the content-addressed store, hash-verified

306}
307
308func TestFirewallDiffJSONSerialization(t *testing.T) {
309 diff := computeFirewallDiff(100, 200, &FirewallAnalysis{
310 RequestsByDomain: map[string]DomainRequestStats{
311 "api.github.com:443": {Allowed: 5, Blocked: 0},
312 },
313 }, &FirewallAnalysis{
314 RequestsByDomain: map[string]DomainRequestStats{
315 "api.github.com:443": {Allowed: 5, Blocked: 0},
316 "new.example.com:443": {Allowed: 3, Blocked: 0},
317 },
318 })
319
320 data, err := json.MarshalIndent(diff, "", " ")
321 require.NoError(t, err, "Should serialize diff to JSON")
322
323 var parsed FirewallDiff
324 err = json.Unmarshal(data, &parsed)
325 require.NoError(t, err, "Should deserialize diff from JSON")
326
327 assert.Equal(t, int64(100), parsed.Run1ID, "Run1ID should survive serialization")
328 assert.Equal(t, int64(200), parsed.Run2ID, "Run2ID should survive serialization")
329 assert.Len(t, parsed.NewDomains, 1, "Should have 1 new domain after deserialization")
330 assert.Equal(t, "new.example.com:443", parsed.NewDomains[0].Domain, "New domain should match")
331}
332
333func TestStatusEmoji(t *testing.T) {
334 assert.Equal(t, "✅", firewallStatusEmoji("allowed"), "Allowed should show checkmark")

Callers

nothing calls this directly

Calls 1

computeFirewallDiffFunction · 0.85

Tested by

no test coverage detected