Skip to content

[plan] Create validation helpers and boundary tests #7529

@github-actions

Description

@github-actions

Objective

Create reusable validation helper functions and comprehensive boundary value tests for the 4 newly validated constraint fields.

Context

After fixing the 4 specific constraint validations, we need:

  1. Reusable validation helpers to prevent code duplication
  2. Comprehensive tests to ensure boundary conditions are properly handled
  3. Documentation of validation patterns for future development

Approach

Part 1: Validation Helpers

Create validation utility functions in appropriate location (e.g., pkg/workflow/validation.go or new pkg/workflow/validation_helpers.go):

func validateIntRange(value, min, max int, fieldName string) error {
    if value < min || value > max {
        return fmt.Errorf("%s must be between %d and %d, got %d",
                          fieldName, min, max, value)
    }
    return nil
}

Part 2: Unit Tests

Create or update test files to cover boundary conditions for each field:

  • pkg/workflow/gateway_test.go - Port validation tests
  • pkg/workflow/repo_memory_test.go - File size/count/retention tests

Test cases for each field:

  • Minimum valid value (should pass)
  • Maximum valid value (should pass)
  • Below minimum (should fail with clear error)
  • Above maximum (should fail with clear error)
  • Zero value (should fail if minimum > 0)
  • Negative value (should fail)

Files to Create/Modify

  • Create or update: pkg/workflow/validation_helpers.go - Reusable validation functions
  • Update: pkg/workflow/gateway_test.go - Port boundary tests
  • Update: pkg/workflow/repo_memory_test.go - File size/count/retention boundary tests

Acceptance Criteria

  • Validation helper function created and documented
  • Port field has 6+ test cases (min, max, below, above, zero, negative)
  • Max-file-size field has 6+ test cases
  • Max-file-count field has 6+ test cases
  • Retention-days field has 6+ test cases
  • All tests pass with make test-unit
  • Code coverage maintained or improved
    Related to [plan] Fix missing constraint validations in parser/compiler #7524

AI generated by Plan Command for discussion #7454

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions