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

Function TestComputeAuditDiff_CombinesAllSections

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

Source from the content-addressed store, hash-verified

578}
579
580func TestComputeAuditDiff_CombinesAllSections(t *testing.T) {
581 summary1 := &RunSummary{
582 RunID: 100,
583 FirewallAnalysis: &FirewallAnalysis{
584 RequestsByDomain: map[string]DomainRequestStats{
585 "api.github.com:443": {Allowed: 5, Blocked: 0},
586 },
587 },
588 MCPToolUsage: &MCPToolUsageData{
589 Summary: []MCPToolSummary{
590 {ServerName: "github", ToolName: "issue_read", CallCount: 3, ErrorCount: 0},
591 },
592 },
593 Run: WorkflowRun{TokenUsage: 2000, Turns: 5},
594 }
595 summary2 := &RunSummary{
596 RunID: 200,
597 FirewallAnalysis: &FirewallAnalysis{
598 RequestsByDomain: map[string]DomainRequestStats{
599 "api.github.com:443": {Allowed: 5, Blocked: 0},
600 "new.example.com:443": {Allowed: 3, Blocked: 0},
601 },
602 },
603 MCPToolUsage: &MCPToolUsageData{
604 Summary: []MCPToolSummary{
605 {ServerName: "github", ToolName: "issue_read", CallCount: 7, ErrorCount: 0},
606 {ServerName: "github", ToolName: "create_issue", CallCount: 2, ErrorCount: 0},
607 },
608 },
609 Run: WorkflowRun{TokenUsage: 3000, Turns: 8},
610 }
611
612 diff := computeAuditDiff(100, 200, summary1, summary2)
613
614 assert.Equal(t, int64(100), diff.Run1ID, "Run1ID should match")
615 assert.Equal(t, int64(200), diff.Run2ID, "Run2ID should match")
616
617 require.NotNil(t, diff.FirewallDiff, "Should have firewall diff")
618 assert.Len(t, diff.FirewallDiff.NewDomains, 1, "Should have 1 new domain")
619
620 require.NotNil(t, diff.MCPToolsDiff, "Should have MCP tools diff")
621 assert.Len(t, diff.MCPToolsDiff.NewTools, 1, "Should have 1 new tool")
622 assert.Len(t, diff.MCPToolsDiff.ChangedTools, 1, "Should have 1 changed tool")
623
624 require.NotNil(t, diff.RunMetricsDiff, "Should have run metrics diff")
625 assert.Equal(t, 2000, diff.RunMetricsDiff.Run1TokenUsage, "Run1 token usage should match")
626 assert.Equal(t, 3000, diff.RunMetricsDiff.Run2TokenUsage, "Run2 token usage should match")
627}
628
629func TestComputeAuditDiff_NilSummaries(t *testing.T) {
630 diff := computeAuditDiff(100, 200, nil, nil)

Callers

nothing calls this directly

Calls 1

computeAuditDiffFunction · 0.85

Tested by

no test coverage detected