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
2 changes: 1 addition & 1 deletion cmd/gh-aw/main_entry_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion pkg/agentdrain/miner_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/cli/audit_expanded_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
})

Expand Down
2 changes: 1 addition & 1 deletion pkg/cli/health_metrics_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 2 additions & 3 deletions pkg/cli/run_workflow_validation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ package cli
import (
"os"
"path/filepath"
"strings"
"testing"

"github.com/stretchr/testify/assert"
Expand Down Expand Up @@ -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")
}
2 changes: 1 addition & 1 deletion pkg/cli/workflows_count_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 1 addition & 2 deletions pkg/console/progress_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ package console

import (
"fmt"
"strings"
"testing"

"github.com/stretchr/testify/assert"
Expand Down Expand Up @@ -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")
})
}
Expand Down
3 changes: 1 addition & 2 deletions pkg/console/verbose_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
2 changes: 1 addition & 1 deletion pkg/parser/frontmatter_helpers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion pkg/parser/import_cache_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
})
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/parser/import_conflict_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions pkg/workflow/codex_logs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
3 changes: 1 addition & 2 deletions pkg/workflow/compiler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion pkg/workflow/lock_schema_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
})
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/workflow/mcp_gateway_entrypoint_mounts_e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)")
}

Expand Down
8 changes: 2 additions & 6 deletions pkg/workflow/safe_outputs_call_workflow_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
24 changes: 12 additions & 12 deletions pkg/workflow/safe_outputs_config_generation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Comment on lines 90 to +96
}

// TestGenerateSafeOutputsConfigActionsCollisionReturnsError tests that a custom action
Expand Down Expand Up @@ -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")
}

Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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")
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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")
}