Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions pkg/cli/audit_expanded_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (
)

func TestExtractEngineConfig(t *testing.T) {
t.Parallel()
tests := []struct {
name string
awInfoContent string
Expand Down Expand Up @@ -54,6 +55,7 @@ func TestExtractEngineConfig(t *testing.T) {

for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
t.Parallel()
if tt.expectNil && tt.awInfoContent == "" {
result := extractEngineConfigWithInferredEngine("", "")
assert.Nil(t, result, "Should return nil for empty logs path")
Expand Down Expand Up @@ -86,6 +88,7 @@ func TestExtractEngineConfig(t *testing.T) {
}

func TestExtractEngineConfigWithDetails(t *testing.T) {
t.Parallel()
tmpDir := testutil.TempDir(t, "engine-config-details-*")
awInfoContent := `{
"engine_id": "copilot",
Expand Down Expand Up @@ -113,6 +116,7 @@ func TestExtractEngineConfigWithDetails(t *testing.T) {
}

func TestExtractEngineConfigInferredWithoutAwInfo(t *testing.T) {
t.Parallel()
tmpDir := testutil.TempDir(t, "engine-infer-*")
logContent := `{"type":"result","subtype":"success","num_turns":3,"usage":{"input_tokens":100,"output_tokens":200}}`
require.NoError(t, os.WriteFile(filepath.Join(tmpDir, "agent-stdio.log"), []byte(logContent), 0o644))
Expand All @@ -124,6 +128,7 @@ func TestExtractEngineConfigInferredWithoutAwInfo(t *testing.T) {
}

func TestInferFallbackLogMetricsFindsNestedAgentStdioLog(t *testing.T) {
t.Parallel()
tmpDir := testutil.TempDir(t, "engine-infer-nested-*")
nestedDir := filepath.Join(tmpDir, "agent", "logs")
require.NoError(t, os.MkdirAll(nestedDir, 0o755))
Expand All @@ -136,6 +141,7 @@ func TestInferFallbackLogMetricsFindsNestedAgentStdioLog(t *testing.T) {
}

func TestExtractPromptAnalysis(t *testing.T) {
t.Parallel()
tests := []struct {
name string
promptContent string
Expand Down Expand Up @@ -184,6 +190,7 @@ func TestExtractPromptAnalysis(t *testing.T) {

for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
t.Parallel()
if tt.name == "empty logs path" {
result := extractPromptAnalysis("")
assert.Nil(t, result, "Should return nil for empty logs path")
Expand Down Expand Up @@ -217,6 +224,7 @@ func TestExtractPromptAnalysis(t *testing.T) {
}

func TestBuildSessionAnalysis(t *testing.T) {
t.Parallel()
tests := []struct {
name string
run WorkflowRun
Expand Down Expand Up @@ -287,6 +295,7 @@ func TestBuildSessionAnalysis(t *testing.T) {

for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
t.Parallel()
processedRun := ProcessedRun{
Run: tt.run,
JobDetails: tt.jobDetails,
Expand Down Expand Up @@ -314,6 +323,7 @@ func TestBuildSessionAnalysis(t *testing.T) {
}

func TestBuildSafeOutputSummary(t *testing.T) {
t.Parallel()
tests := []struct {
name string
items []CreatedItemReport
Expand Down Expand Up @@ -382,6 +392,7 @@ func TestBuildSafeOutputSummary(t *testing.T) {

for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
t.Parallel()
result := buildSafeOutputSummary(tt.items, tt.chainMetrics)
if tt.expectNil {
assert.Nil(t, result, "Should return nil for empty items")
Expand All @@ -405,6 +416,7 @@ func TestBuildSafeOutputSummary(t *testing.T) {
}

func TestBuildSafeOutputSummaryString(t *testing.T) {
t.Parallel()
tests := []struct {
name string
details []SafeOutputTypeDetail
Expand Down Expand Up @@ -434,20 +446,23 @@ func TestBuildSafeOutputSummaryString(t *testing.T) {

for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
t.Parallel()
result := buildSafeOutputSummaryString(tt.details)
assert.Equal(t, tt.expected, result, "Summary string should match")
})
}
}

func TestPrettifySafeOutputType(t *testing.T) {
t.Parallel()
assert.Equal(t, "PR(s)", prettifySafeOutputType("create_pull_request"), "Should prettify PR type")
assert.Equal(t, "issue(s)", prettifySafeOutputType("create_issue"), "Should prettify issue type")
assert.Equal(t, "comment(s)", prettifySafeOutputType("add_comment"), "Should prettify comment type")
assert.Equal(t, "custom_type", prettifySafeOutputType("custom_type"), "Should return unknown types as-is")
}

func TestBuildMCPServerHealth(t *testing.T) {
t.Parallel()
tests := []struct {
name string
mcpUsage *MCPToolUsageData
Expand Down Expand Up @@ -488,6 +503,7 @@ func TestBuildMCPServerHealth(t *testing.T) {

for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
t.Parallel()
result := buildMCPServerHealth(tt.mcpUsage, tt.mcpFailures)
if tt.expectNil {
assert.Nil(t, result, "Should return nil when both inputs are nil/empty")
Expand All @@ -506,6 +522,7 @@ func TestBuildMCPServerHealth(t *testing.T) {
}

func TestBuildMCPServerHealthErrorRate(t *testing.T) {
t.Parallel()
mcpUsage := &MCPToolUsageData{
Servers: []MCPServerStats{
{ServerName: "github", RequestCount: 100, ToolCallCount: 80, ErrorCount: 15, AvgDuration: "200ms"},
Expand All @@ -525,6 +542,7 @@ func TestBuildMCPServerHealthErrorRate(t *testing.T) {
}

func TestBuildSlowestToolCalls(t *testing.T) {
t.Parallel()
calls := []MCPToolCall{
{ServerName: "github", ToolName: "search_code", Duration: "100ms"},
{ServerName: "github", ToolName: "get_file", Duration: "500ms"},
Expand All @@ -542,6 +560,7 @@ func TestBuildSlowestToolCalls(t *testing.T) {
}

func TestBuildSlowestToolCallsEmpty(t *testing.T) {
t.Parallel()
result := buildSlowestToolCalls(nil, 5)
assert.Nil(t, result, "Should return nil for empty calls")

Expand All @@ -550,6 +569,7 @@ func TestBuildSlowestToolCallsEmpty(t *testing.T) {
}

func TestBuildAuditDataWithExpandedSections(t *testing.T) {
t.Parallel()
tmpDir := testutil.TempDir(t, "audit-expanded-*")

// Create test aw_info.json in activation/ subdir (unflattened artifact structure)
Expand Down Expand Up @@ -651,6 +671,7 @@ func TestBuildAuditDataWithExpandedSections(t *testing.T) {
}

func TestBuildAuditDataExpandedWithNoData(t *testing.T) {
t.Parallel()
// Test that expanded sections are nil when no data is available
processedRun := ProcessedRun{
Run: WorkflowRun{
Expand All @@ -672,6 +693,7 @@ func TestBuildAuditDataExpandedWithNoData(t *testing.T) {
}

func TestAwInfoHasMCPServers(t *testing.T) {
t.Parallel()
tests := []struct {
name string
awInfoContent string
Expand Down Expand Up @@ -706,6 +728,7 @@ func TestAwInfoHasMCPServers(t *testing.T) {

for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
t.Parallel()
tmpDir := testutil.TempDir(t, "mcp-servers-*")
targetDir := tmpDir
if tt.awInfoSubdir != "" {
Expand Down
3 changes: 3 additions & 0 deletions pkg/cli/bootstrap_profile_git_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
)

func TestRunBootstrapCommitAndPushAction_CommitsAndPushesChanges(t *testing.T) {
t.Parallel()
repoDir := initBootstrapGitRepo(t)
remoteDir := t.TempDir()

Expand Down Expand Up @@ -74,6 +75,7 @@ func TestRunBootstrapCommitAndPushAction_CommitsAndPushesChanges(t *testing.T) {
}

func TestRunBootstrapCommitAndPushAction_RequiresRepoDir(t *testing.T) {
t.Parallel()
if err := runBootstrapCommitAndPushAction(context.Background(), "", repositoryPackageBootstrapAction{
Type: "commit-and-push",
Message: "Bootstrap repository changes",
Expand All @@ -83,6 +85,7 @@ func TestRunBootstrapCommitAndPushAction_RequiresRepoDir(t *testing.T) {
}

func TestRunBootstrapCommitAndPushAction_SkipsCleanCheckout(t *testing.T) {
t.Parallel()
repoDir := initBootstrapGitRepo(t)
runRepoGit := func(args ...string) {
t.Helper()
Expand Down
10 changes: 10 additions & 0 deletions pkg/cli/cli_consistency_help_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (
)

func TestAuditCommandDescriptionsAreConsistent(t *testing.T) {
t.Parallel()
cmd := NewAuditCommand()

assert.Contains(t, cmd.Short, "workflow runs", "audit short description should describe multiple run inputs")
Expand All @@ -23,6 +24,7 @@ func TestAuditCommandDescriptionsAreConsistent(t *testing.T) {
}

func TestTrialCommandUsesStandardExamplesHeading(t *testing.T) {
t.Parallel()
cmd := NewTrialCommand(func(string) error { return nil })

assert.NotEmpty(t, cmd.Example, "trial command should use cobra's Example field for examples")
Expand All @@ -36,6 +38,7 @@ func TestTrialCommandUsesStandardExamplesHeading(t *testing.T) {
}

func TestUpdateDocsIncludeCoolDownOption(t *testing.T) {
t.Parallel()
_, currentFile, _, ok := runtime.Caller(0)
require.True(t, ok, "should resolve current test file path")

Expand All @@ -52,6 +55,7 @@ func TestUpdateDocsIncludeCoolDownOption(t *testing.T) {
}

func TestCompileDocsReflectCurrentOptions(t *testing.T) {
t.Parallel()
_, currentFile, _, ok := runtime.Caller(0)
require.True(t, ok, "should resolve current test file path")

Expand All @@ -69,6 +73,7 @@ func TestCompileDocsReflectCurrentOptions(t *testing.T) {
}

func TestCLIDocsReflectStatusAuditAndExperimentsCommands(t *testing.T) {
t.Parallel()
_, currentFile, _, ok := runtime.Caller(0)
require.True(t, ok, "should resolve current test file path")

Expand Down Expand Up @@ -96,6 +101,7 @@ func TestCLIDocsReflectStatusAuditAndExperimentsCommands(t *testing.T) {
}

func TestSubcommandListingsUseHyphenBullets(t *testing.T) {
t.Parallel()
tests := []struct {
name string
longDoc string
Expand All @@ -115,6 +121,7 @@ func TestSubcommandListingsUseHyphenBullets(t *testing.T) {
}

func TestSubcommandListingsMatchCobraShortDescriptions(t *testing.T) {
t.Parallel()
t.Run("secrets bootstrap", func(t *testing.T) {
cmd := NewSecretsCommand()
bootstrapCmd, _, err := cmd.Find([]string{"bootstrap"})
Expand All @@ -135,6 +142,7 @@ func TestSubcommandListingsMatchCobraShortDescriptions(t *testing.T) {
}

func TestHelpTextUsesStandardEgPunctuation(t *testing.T) {
t.Parallel()
assert.Contains(t, coolDownFlagUsage, "(e.g., 7d", "--cool-down help should use e.g., punctuation")
assert.Contains(t, NewEnvCommand().Long, "(e.g., default_max_turns)", "env help should use e.g., punctuation")
assert.Contains(t, NewDomainsCommand().Long, "(e.g., \"node\", \"python\", \"github\")", "domains help should use e.g., punctuation")
Expand All @@ -144,6 +152,7 @@ func TestHelpTextUsesStandardEgPunctuation(t *testing.T) {
}

func TestLegacyNestedGHHelpIsRejected(t *testing.T) {
t.Parallel()
tests := []struct {
name string
newCmd func() *cobra.Command
Expand All @@ -160,6 +169,7 @@ func TestLegacyNestedGHHelpIsRejected(t *testing.T) {

for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
t.Parallel()
cmd := tt.newCmd()
cmd.SilenceUsage = true
cmd.SilenceErrors = true
Expand Down
Loading