Skip to content

[US-054-T2] Add bundle validate CLI command with TDD #205

Description

@KochTobi-Agent

Task Description

Implement the oc bundle validate [PATH] CLI command using TDD (red-to-green approach).

TDD Cycle

RED Phase - Write Failing Tests

Create comprehensive tests in cmd/bundle_test.go:

  • TestBundleValidateCommand_ValidBundle - validates valid bundle, exits 0
  • TestBundleValidateCommand_InvalidBundle - validates invalid bundle, exits 1
  • TestBundleValidateCommand_DefaultPath - uses current directory when no PATH arg
  • TestBundleValidateCommand_ArchivePath - validates .tar.gz archive path
  • TestBundleValidateCommand_NonExistentPath - handles non-existent path gracefully
  • TestBundleValidateCommand_FormattedOutput - errors formatted with styles package

GREEN Phase - Implement to Pass

Add to cmd/bundle.go:

  • bundleValidateCmd cobra.Command with:
    • Use: "validate [PATH]"
    • Short: "Validate bundle structure and manifest"
    • Args: cobra.MaximumNArgs(1)
    • RunE: runBundleValidate
  • runBundleValidate(cmd *cobra.Command, args []string) error function:
    • Resolve path (default to "." if no arg)
    • Use bundle.ResolveToLocal() for directory/archive normalization
    • Call bundle.ValidateBundle() from T1
    • Print errors with styles.Error(), warnings with styles.Warning()
    • Exit code 0 on valid, 1 on validation errors, 2 on system errors

Acceptance Criteria

  • All CLI tests written and initially failing
  • Command implementation passes all tests
  • Exit codes: 0 = success, 1 = validation errors, 2 = system/IO errors
  • Works with both directories and .tar.gz archives
  • Default path (current directory) works when no argument provided
  • Follows existing command patterns in cmd/bundle.go

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    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