Skip to content

[task] Add test coverage for critical untested Go files #3771

@github-actions

Description

@github-actions

Objective

Create comprehensive unit tests for three critical files that currently lack test coverage: pkg/workflow/safe_outputs.go, pkg/workflow/scripts.go, and pkg/cli/compile_command.go.

Context

These files handle core functionality (safe output processing, script generation, and workflow compilation commands) and should have comprehensive test coverage. Part of discussion #3770.

Approach

1. Create pkg/workflow/safe_outputs_test.go

  • Test all safe output types: create-issue, create-discussion, add-comment, create-pull-request, etc.
  • Test output parsing and validation logic
  • Test error handling for malformed output
  • Use table-driven tests for different output configurations

2. Create pkg/workflow/scripts_test.go

  • Test script embedding and retrieval functions
  • Test JavaScript bundling logic
  • Test script generation for different engines (copilot, claude, codex)
  • Validate generated script syntax and structure

3. Create pkg/cli/compile_command_test.go

  • Test workflow compilation command execution
  • Test --strict flag behavior
  • Test --purge flag functionality
  • Test error reporting and validation
  • Mock file system operations where appropriate

Files to Create

  • pkg/workflow/safe_outputs_test.go
  • pkg/workflow/scripts_test.go
  • pkg/cli/compile_command_test.go

Acceptance Criteria

  • All three test files created with comprehensive coverage
  • Achieve minimum 80% code coverage for each file
  • Include edge cases: empty inputs, malformed data, error conditions
  • Follow existing test patterns (table-driven tests, standard library, error validation)
  • Add descriptive test names (e.g., TestSafeOutputsCreateIssue_WithValidInput)
  • All tests pass with make test-unit
    Related to 🎯 Repository Quality Improvement Report - Testing Infrastructure #3770

AI generated by Plan Command for discussion #3770

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions