diff --git a/cmd/gh-aw/main_entry_test.go b/cmd/gh-aw/main_entry_test.go index 197bc89b33a..ad1be108d93 100644 --- a/cmd/gh-aw/main_entry_test.go +++ b/cmd/gh-aw/main_entry_test.go @@ -272,7 +272,7 @@ func TestMainFunctionExecutionPath(t *testing.T) { // Check that it's an ExitError (non-zero exit code) exitError, ok := err.(*exec.ExitError) require.True(t, ok, "invalid command should return an *exec.ExitError, got %T", err) - assert.NotEqual(t, 0, exitError.ExitCode(), "invalid command should return a non-zero exit code") + assert.NotZero(t, exitError.ExitCode(), "invalid command should return a non-zero exit code") }) t.Run("main function version info setup", func(t *testing.T) { diff --git a/pkg/agentdrain/miner_test.go b/pkg/agentdrain/miner_test.go index f75f350cf26..9917effa120 100644 --- a/pkg/agentdrain/miner_test.go +++ b/pkg/agentdrain/miner_test.go @@ -296,7 +296,7 @@ func TestConcurrency(t *testing.T) { for i := range linesEach { line := fmt.Sprintf("stage=work goroutine=%d iter=%d", id, i) _, trainErr := m.Train(line) - assert.NoError(t, trainErr, "Train should not error during concurrent access") + require.NoError(t, trainErr, "Train should not error during concurrent access") } }(g) } diff --git a/pkg/cli/audit_expanded_test.go b/pkg/cli/audit_expanded_test.go index 0457504b8ba..f8da7caeb86 100644 --- a/pkg/cli/audit_expanded_test.go +++ b/pkg/cli/audit_expanded_test.go @@ -614,7 +614,7 @@ func TestBuildAuditDataWithExpandedSections(t *testing.T) { t.Run("PromptAnalysis", func(t *testing.T) { require.NotNil(t, auditData.PromptAnalysis, "Prompt analysis should be populated") - assert.Equal(t, len(promptContent), auditData.PromptAnalysis.PromptSize, "Prompt size should match") + assert.Len(t, promptContent, auditData.PromptAnalysis.PromptSize, "Prompt size should match") assert.Equal(t, filepath.Join("activation", "aw-prompts", "prompt.txt"), auditData.PromptAnalysis.PromptFile, "Prompt file should be a relative path") }) diff --git a/pkg/cli/health_metrics_test.go b/pkg/cli/health_metrics_test.go index add5f944c0f..6a87f588159 100644 --- a/pkg/cli/health_metrics_test.go +++ b/pkg/cli/health_metrics_test.go @@ -78,7 +78,7 @@ func TestCalculateWorkflowHealth(t *testing.T) { } if len(tt.runs) > 0 { - assert.Equal(t, len(tt.runs), health.TotalRuns, "Total runs should match") + assert.Len(t, tt.runs, health.TotalRuns, "Total runs should match") } // Check below threshold flag diff --git a/pkg/cli/run_workflow_validation_test.go b/pkg/cli/run_workflow_validation_test.go index a78e31e820e..dedc746b752 100644 --- a/pkg/cli/run_workflow_validation_test.go +++ b/pkg/cli/run_workflow_validation_test.go @@ -5,7 +5,6 @@ package cli import ( "os" "path/filepath" - "strings" "testing" "github.com/stretchr/testify/assert" @@ -431,6 +430,6 @@ jobs: err = validateWorkflowInputs(markdownPath, []string{"issue_ur=https://example.com"}) require.Error(t, err) assert.Contains(t, err.Error(), "Invalid input name") - assert.True(t, strings.Contains(err.Error(), "issue_ur") && strings.Contains(err.Error(), "issue_url"), - "Error should suggest correct input name") + assert.Contains(t, err.Error(), "issue_ur", "Error should include invalid input") + assert.Contains(t, err.Error(), "issue_url", "Error should suggest correct input name") } diff --git a/pkg/cli/workflows_count_test.go b/pkg/cli/workflows_count_test.go index 90f669203af..5c309fa687a 100644 --- a/pkg/cli/workflows_count_test.go +++ b/pkg/cli/workflows_count_test.go @@ -78,7 +78,7 @@ func TestWorkflowCounting(t *testing.T) { } // Verify counts - assert.Equal(t, len(mdWorkflowNames), userWorkflowCount, "User workflow count should match .md file count") + assert.Len(t, mdWorkflowNames, userWorkflowCount, "User workflow count should match .md file count") // Verify message format (internal workflows are never mentioned) var message string diff --git a/pkg/console/progress_test.go b/pkg/console/progress_test.go index 5f7f03e452f..0c798d27ca3 100644 --- a/pkg/console/progress_test.go +++ b/pkg/console/progress_test.go @@ -4,7 +4,6 @@ package console import ( "fmt" - "strings" "testing" "github.com/stretchr/testify/assert" @@ -259,7 +258,7 @@ func TestProgressBarOutputFormat(t *testing.T) { // Should contain: percentage, current size, total size assert.Contains(t, output, "%", "Output should contain percentage symbol") - assert.True(t, strings.Contains(output, "KB") || strings.Contains(output, "MB"), "Output should contain size units") + assert.Regexp(t, `KB|MB`, output, "Output should contain size units") assert.Contains(t, output, "/", "Output should contain separator between current and total") }) } diff --git a/pkg/console/verbose_test.go b/pkg/console/verbose_test.go index 52939bdc57f..a08758ec932 100644 --- a/pkg/console/verbose_test.go +++ b/pkg/console/verbose_test.go @@ -65,8 +65,7 @@ func TestLogVerbose(t *testing.T) { // Should contain the message assert.Contains(t, output, tt.message, "Output should contain the message when verbose is enabled") // Should contain the verbose icon (🔍) - assert.True(t, strings.Contains(output, "🔍") || strings.Contains(output, tt.message), - "Output should contain verbose formatting or message") + assert.Contains(t, output, "🔍", "Output should contain verbose formatting") } else { // Should be empty assert.Empty(t, output, "Output should be empty when verbose is disabled") diff --git a/pkg/parser/frontmatter_helpers_test.go b/pkg/parser/frontmatter_helpers_test.go index fb88583edf1..97d7bdcf372 100644 --- a/pkg/parser/frontmatter_helpers_test.go +++ b/pkg/parser/frontmatter_helpers_test.go @@ -190,7 +190,7 @@ func TestEnsureToolsSection(t *testing.T) { // Verify reference identity: mutating the returned map must be visible via frontmatter tools["__probe__"] = true - assert.Equal(t, true, frontmatterTools["__probe__"], "returned tools should be the same map stored in frontmatter['tools']") + assert.True(t, frontmatterTools["__probe__"].(bool), "returned tools should be the same map stored in frontmatter['tools']") delete(tools, "__probe__") // Verify returned tools matches the expected content diff --git a/pkg/parser/import_cache_test.go b/pkg/parser/import_cache_test.go index 2a5677386b4..4015dba61f1 100644 --- a/pkg/parser/import_cache_test.go +++ b/pkg/parser/import_cache_test.go @@ -288,7 +288,7 @@ func TestValidatePathComponents(t *testing.T) { require.Error(t, err, "should return error for: %s", tt.name) assert.Contains(t, err.Error(), tt.errMsg, "error message should mention: %s", tt.errMsg) } else { - assert.NoError(t, err, "should not return error for valid components") + require.NoError(t, err, "should not return error for valid components") } }) } diff --git a/pkg/parser/import_conflict_test.go b/pkg/parser/import_conflict_test.go index 84174a89577..af920761019 100644 --- a/pkg/parser/import_conflict_test.go +++ b/pkg/parser/import_conflict_test.go @@ -125,7 +125,7 @@ permissions: } _, err := parser.ProcessImportsFromFrontmatterWithSource(frontmatter, tempDir, nil, mainPath, mainContent) - assert.NoError(t, err, "Importing the same file twice with identical 'with' values should be allowed") + require.NoError(t, err, "Importing the same file twice with identical 'with' values should be allowed") } // TestImportConflict_SameFileTwiceNoWith tests that importing the same file (no 'with') @@ -166,7 +166,7 @@ permissions: } _, err := parser.ProcessImportsFromFrontmatterWithSource(frontmatter, tempDir, nil, mainPath, mainContent) - assert.NoError(t, err, "Importing the same file (no 'with') twice should be silently deduplicated") + require.NoError(t, err, "Importing the same file (no 'with') twice should be silently deduplicated") } // TestImportConflict_NestedConflict tests that a conflict detected via nested imports diff --git a/pkg/workflow/codex_logs_test.go b/pkg/workflow/codex_logs_test.go index f68f9adc345..b261d96e7bd 100644 --- a/pkg/workflow/codex_logs_test.go +++ b/pkg/workflow/codex_logs_test.go @@ -92,8 +92,8 @@ func TestCodexParseLogMetricsMultipleToolsWithOutputSizes(t *testing.T) { require.NotNil(t, searchPRTool, "search_pull_requests tool should be found") // Verify output sizes - assert.Equal(t, len("[]"), listPRTool.MaxOutputSize, "list_pull_requests output size") - assert.Equal(t, len("[{\"number\":123,\"title\":\"Test PR\"}]"), searchPRTool.MaxOutputSize, "search_pull_requests output size") + assert.Len(t, "[]", listPRTool.MaxOutputSize, "list_pull_requests output size") + assert.Len(t, "[{\"number\":123,\"title\":\"Test PR\"}]", searchPRTool.MaxOutputSize, "search_pull_requests output size") } func TestCodexParseLogMetricsNoOutputSize(t *testing.T) { diff --git a/pkg/workflow/compiler_test.go b/pkg/workflow/compiler_test.go index 0fcbf90ef85..bf0a4cb84fb 100644 --- a/pkg/workflow/compiler_test.go +++ b/pkg/workflow/compiler_test.go @@ -365,8 +365,7 @@ This workflow is missing the required 'on' field. // Error should contain file reference errorStr := err.Error() - assert.True(t, strings.Contains(errorStr, "invalid.md") || strings.Contains(errorStr, "error"), - "Error should reference the file or contain 'error'") + assert.Regexp(t, `invalid\.md|error`, errorStr, "Error should reference the file or contain 'error'") } // TestCompileWorkflow_PathTraversal tests that path traversal attempts are handled safely diff --git a/pkg/workflow/lock_schema_test.go b/pkg/workflow/lock_schema_test.go index 0af355ae2db..ac1a4582180 100644 --- a/pkg/workflow/lock_schema_test.go +++ b/pkg/workflow/lock_schema_test.go @@ -214,7 +214,7 @@ name: test assert.Contains(t, err.Error(), tt.errorText, "Error message should contain expected text") } } else { - assert.NoError(t, err, "Should not error on compatible schema") + require.NoError(t, err, "Should not error on compatible schema") } }) } diff --git a/pkg/workflow/mcp_gateway_entrypoint_mounts_e2e_test.go b/pkg/workflow/mcp_gateway_entrypoint_mounts_e2e_test.go index 6212ca6beca..a3c6b93598e 100644 --- a/pkg/workflow/mcp_gateway_entrypoint_mounts_e2e_test.go +++ b/pkg/workflow/mcp_gateway_entrypoint_mounts_e2e_test.go @@ -269,7 +269,7 @@ Test that entrypoint with special characters in args is properly handled. // Verify args with special characters are properly handled assert.Contains(t, yamlStr, "bash", "Compiled YAML should contain bash arg") // The exact format of the shell-quoted command may vary, but it should contain the key parts - assert.True(t, strings.Contains(yamlStr, "Hello World") || strings.Contains(yamlStr, "Hello\\ World"), + assert.Regexp(t, `Hello(?: |\\ )World`, yamlStr, "Compiled YAML should contain the command string (possibly escaped)") } diff --git a/pkg/workflow/safe_outputs_call_workflow_test.go b/pkg/workflow/safe_outputs_call_workflow_test.go index 58b26c3e3ae..49e965f381a 100644 --- a/pkg/workflow/safe_outputs_call_workflow_test.go +++ b/pkg/workflow/safe_outputs_call_workflow_test.go @@ -580,10 +580,6 @@ Analyse the issue and determine which worker to run. assert.Contains(t, yamlOutput, "call_workflow_payload", "Should reference call_workflow_payload") // Verify if conditions - assert.True(t, strings.Contains(yamlOutput, "call_workflow_name == 'worker-a'") || - strings.Contains(yamlOutput, "call_workflow_name == \"worker-a\""), - "Should contain if condition for worker-a") - assert.True(t, strings.Contains(yamlOutput, "call_workflow_name == 'worker-b'") || - strings.Contains(yamlOutput, "call_workflow_name == \"worker-b\""), - "Should contain if condition for worker-b") + assert.Regexp(t, `call_workflow_name == ['"]worker-a['"]`, yamlOutput, "Should contain if condition for worker-a") + assert.Regexp(t, `call_workflow_name == ['"]worker-b['"]`, yamlOutput, "Should contain if condition for worker-b") } diff --git a/pkg/workflow/safe_outputs_config_generation_test.go b/pkg/workflow/safe_outputs_config_generation_test.go index c7552008fba..fa2eb6b3b7e 100644 --- a/pkg/workflow/safe_outputs_config_generation_test.go +++ b/pkg/workflow/safe_outputs_config_generation_test.go @@ -89,11 +89,11 @@ func TestGenerateSafeOutputsConfigActions(t *testing.T) { // registers it. Names are normalized (hyphens converted to underscores). uploadVal, hasUploadReport := parsed["upload_report"] assert.True(t, hasUploadReport, "Expected upload_report key in config") - assert.Equal(t, true, uploadVal, "upload_report value should be true") + assert.True(t, uploadVal.(bool), "upload_report value should be true") publishVal, hasPublishResults := parsed["publish_results"] assert.True(t, hasPublishResults, "Expected publish_results key in config (hyphen normalized to underscore)") - assert.Equal(t, true, publishVal, "publish_results value should be true") + assert.True(t, publishVal.(bool), "publish_results value should be true") } // TestGenerateSafeOutputsConfigActionsCollisionReturnsError tests that a custom action @@ -181,8 +181,8 @@ func TestGenerateSafeOutputsConfigMentions(t *testing.T) { mentions, ok := parsed["mentions"].(map[string]any) require.True(t, ok, "Expected mentions key in config") - assert.Equal(t, true, mentions["enabled"], "enabled should be true") - assert.Equal(t, false, mentions["allowTeamMembers"], "allowTeamMembers should be false") + assert.True(t, mentions["enabled"].(bool), "enabled should be true") + assert.False(t, mentions["allowTeamMembers"].(bool), "allowTeamMembers should be false") assert.InDelta(t, float64(5), mentions["max"], 0.0001, "max should be 5") } @@ -263,7 +263,7 @@ func TestGenerateCustomJobToolDefinition(t *testing.T) { schema, ok := result["inputSchema"].(map[string]any) require.True(t, ok, "inputSchema should be a map") assert.Equal(t, "object", schema["type"], "schema type should be object") - assert.Equal(t, false, schema["additionalProperties"], "additionalProperties should be false") + assert.False(t, schema["additionalProperties"].(bool), "additionalProperties should be false") props, ok := schema["properties"].(map[string]any) require.True(t, ok, "properties should be a map") titleProp, ok := props["title"].(map[string]any) @@ -474,7 +474,7 @@ func TestGenerateSafeOutputsConfigCreatePullRequestTargetRepo(t *testing.T) { assert.Equal(t, "caido/other-repo", allowedRepos[0], "allowed_repos should match") assert.Equal(t, "dev", prConfig["base_branch"], "base_branch should be set") - assert.Equal(t, true, prConfig["draft"], "draft should be true") + assert.True(t, prConfig["draft"].(bool), "draft should be true") reviewers, ok := prConfig["reviewers"].([]any) require.True(t, ok, "reviewers should be an array") @@ -487,7 +487,7 @@ func TestGenerateSafeOutputsConfigCreatePullRequestTargetRepo(t *testing.T) { assert.Equal(t, "platform-reviewers", teamReviewers[0], "team reviewer should match") assert.Equal(t, "[refactor] ", prConfig["title_prefix"], "title_prefix should be set") - assert.Equal(t, false, prConfig["fallback_as_issue"], "fallback_as_issue should be false") + assert.False(t, prConfig["fallback_as_issue"].(bool), "fallback_as_issue should be false") } // TestGenerateSafeOutputsConfigCreatePullRequestBackwardCompat tests that config without @@ -516,8 +516,8 @@ func TestGenerateSafeOutputsConfigCreatePullRequestBackwardCompat(t *testing.T) require.True(t, ok, "Expected create_pull_request key in config") assert.InDelta(t, float64(2), prConfig["max"], 0.0001, "max should be 2") - assert.Equal(t, true, prConfig["allow_empty"], "allow_empty should be true") - assert.Equal(t, true, prConfig["auto_merge"], "auto_merge should be true") + assert.True(t, prConfig["allow_empty"].(bool), "allow_empty should be true") + assert.True(t, prConfig["auto_merge"].(bool), "auto_merge should be true") assert.InDelta(t, float64(24), prConfig["expires"], 0.0001, "expires should be 24") // target-repo and allowed_repos should not be present when not configured @@ -611,7 +611,7 @@ func TestGenerateSafeOutputsConfigCreatePullRequestAutoCloseIssue(t *testing.T) prConfig, ok := parsed["create_pull_request"].(map[string]any) require.True(t, ok, "Expected create_pull_request key in config") - assert.Equal(t, false, prConfig["auto_close_issue"], "auto_close_issue should be false") + assert.False(t, prConfig["auto_close_issue"].(bool), "auto_close_issue should be false") } // TestGenerateSafeOutputsConfigCreatePullRequestAutoCloseIssueExpression tests that @@ -825,7 +825,7 @@ func TestGenerateSafeOutputsConfigReplyToPullRequestReviewCommentWithTarget(t *t assert.Len(t, allowedRepos, 1, "Should have 1 allowed repo") assert.Equal(t, "org/other-repo", allowedRepos[0], "allowed_repos entry should match") - assert.Equal(t, true, replyConfig["footer"], "footer should be true") + assert.True(t, replyConfig["footer"].(bool), "footer should be true") } // TestGenerateSafeOutputsConfigClosePullRequest tests that generateSafeOutputsConfig correctly @@ -901,6 +901,6 @@ func TestGenerateSafeOutputsConfigClosePullRequestStaged(t *testing.T) { closePRConfig, ok := parsed["close_pull_request"].(map[string]any) require.True(t, ok, "Expected close_pull_request key in config.json") - assert.Equal(t, true, closePRConfig["staged"], "staged should be true") + assert.True(t, closePRConfig["staged"].(bool), "staged should be true") assert.Nil(t, closePRConfig["github-token"], "github-token should not be set when empty") }