Skip to content

Conversation

@github-actions
Copy link
Contributor

@github-actions github-actions bot commented Nov 4, 2025

Summary

This PR adds comprehensive unit tests for the describeTrigger() method in pkg/cli/interactive.go, which previously had only 18.2% coverage.

Changes Made

Enhanced Test File

pkg/cli/interactive_test.go - Added 11 test cases covering:

  1. All defined trigger types:

    • workflow_dispatch → "Manual trigger"
    • issues → "Issue opened or reopened"
    • pull_request → "Pull request opened or synchronized"
    • push → "Push to main branch"
    • issue_comment → "Issue comment created"
    • schedule_daily → "Daily schedule (9 AM UTC)"
    • schedule_weekly → "Weekly schedule (Monday 9 AM UTC)"
    • command → "Command trigger (/bot-name)"
    • custom → "Custom trigger (TODO: configure)"
  2. Edge cases:

    • Unknown trigger types → "Unknown trigger"
    • Empty string trigger → "Unknown trigger"

Test Coverage Results

Function Before After Improvement
describeTrigger() 18.2% 100.0% +81.8%
pkg/cli/interactive.go file 28.9% 29.0% +0.1%
Overall Repository 66.7% 66.7% +0.0%

Replicating the Test Coverage Measurements

# Install dependencies (if needed)
make deps

# Build the project
make build

# Run tests with coverage (before)
git checkout main
go test -count=1 -timeout=5m -coverprofile=coverage-before.out -covermode=atomic ./...
go tool cover -func=coverage-before.out | grep total
# Output: total: (statements) 66.7%

# Run tests with coverage (after)
git checkout test-coverage-describe-trigger-1762223850
go test -count=1 -timeout=5m -coverprofile=coverage-after.out -covermode=atomic ./...
go tool cover -func=coverage-after.out | grep total
# Output: total: (statements) 66.7%

# Compare specific function
echo "=== BEFORE ==="
go tool cover -func=coverage-before.out | grep "describeTrigger"
# Output: describeTrigger 18.2%
echo "=== AFTER ==="
go tool cover -func=coverage-after.out | grep "describeTrigger"
# Output: describeTrigger 100.0%

# Run just the new tests
go test -v -run "TestInteractiveWorkflowBuilder_describeTrigger" ./pkg/cli/
# All 11 subtests pass

Problems Found

None - this is a pure string formatting function with straightforward switch statement logic.

Actions Taken

  1. Added 11 test cases covering all switch statement branches
  2. Tested all trigger types defined in the function
  3. Added edge case tests for unknown and empty triggers
  4. Verified all tests pass successfully
  5. Formatted code with make fmt
  6. All tests pass with 100% coverage for the targeted function

Future Improvement Areas

Based on current coverage analysis, the following pkg/cli/interactive.go functions still have low or zero coverage:

Zero Coverage Functions (0%):

  • CreateWorkflowInteractively() - Main interactive workflow builder
  • promptForWorkflowName() - User input prompting
  • promptForTrigger() - Trigger selection
  • promptForEngine() - Engine selection
  • promptForTools() - Tools selection
  • promptForSafeOutputs() - Safe outputs configuration
  • promptForNetworkAccess() - Network access configuration
  • promptForIntent() - Intent description
  • generateWorkflow() - Workflow generation
  • compileWorkflow() - Workflow compilation

Medium Coverage (40-100%):

  • generateTriggerConfig() - 40.0% coverage
  • generateNetworkConfig() - 66.7% coverage
  • generateToolsConfig() - 80.0% coverage
  • generateSafeOutputsConfig() - 85.7% coverage
  • generateWorkflowContent() - 100.0% coverage
  • generatePermissionsConfig() - 100.0% coverage

The zero-coverage functions are integration-heavy (require user input/prompts) and would need mocking infrastructure. The partially-covered generator functions could benefit from additional edge case testing.


📋 Full Command History

Bash Commands Run

# Phase determination
cd /home/runner/work/gh-aw/gh-aw
tail -1 coverage-summary.txt

# Create branch
git checkout -b test-coverage-describe-trigger-1762223850

# Run new tests
go test -v -run "^TestInteractiveWorkflowBuilder_describeTrigger$" ./pkg/cli/

# Generate coverage report
go test -count=1 -timeout=5m -coverprofile=coverage-new.out -covermode=atomic ./...
go tool cover -func=coverage-new.out | tail -1

# Compare before/after
echo "=== BEFORE ==="
go tool cover -func=coverage.out | grep "interactive.go.*describeTrigger"
echo "=== AFTER ==="
go tool cover -func=coverage-new.out | grep "interactive.go.*describeTrigger"

# Format code
make fmt

# Commit changes
git add pkg/cli/interactive_test.go
git commit -m "test: add comprehensive tests for InteractiveWorkflowBuilder.describeTrigger (+81.8% function coverage, +0.0% overall)"

Web Searches Performed

None

Web Pages Fetched

None

AI generated by Daily Test Coverage Improver

AI generated by Daily Test Coverage Improver

@dsyme dsyme marked this pull request as ready for review November 4, 2025 14:51
Copilot AI review requested due to automatic review settings November 4, 2025 14:51
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds comprehensive test coverage for the describeTrigger() method in the InteractiveWorkflowBuilder struct.

  • Adds a new test function TestInteractiveWorkflowBuilder_describeTrigger with 11 test cases
  • Tests cover all trigger types handled by the describeTrigger() method (workflow_dispatch, issues, pull_request, push, issue_comment, schedule_daily, schedule_weekly, command, custom)
  • Tests include edge cases for unknown and empty trigger values

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@pelikhan pelikhan merged commit 26f3222 into main Nov 4, 2025
15 checks passed
@pelikhan pelikhan deleted the test-coverage-describe-trigger-1762223850-ec4d0594c702875b branch November 4, 2025 17:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants