Skip to content

test: add unit tests for canon/parse.go — Parse, splitChain, tokenize #14

@jpleva91

Description

@jpleva91

Problem

canon/parse.go has zero test coverage. This is the core command parser — it splits chains (&&, ||, ;, |), respects quoting, extracts tools/actions/flags/args. Bugs here affect every governance decision.

Acceptance Criteria

  • Test Parse() splits && chains into multiple segments with correct OpAnd
  • Test Parse() splits || chains with OpOr
  • Test Parse() splits pipes | with OpPipe
  • Test Parse() splits semicolons ; with OpSeq
  • Test quoted strings are not split (single and double quotes)
  • Test escaped characters are preserved
  • Test ParseOne() for simple single commands
  • Test tokenize() respects quoting and backslash escapes
  • Test parseFlag() splits --count=5 into name/value
  • Test expandShortFlags() expands -rn to ["-r", "-n"] but not --verbose or -C5
  • Test empty/whitespace input edge cases
  • All tests pass with go test ./canon/...

Hints

  • File: canon/parse.go
  • Functions: Parse(), ParseOne(), splitChain(), tokenize(), parseOne(), parseFlag(), expandShortFlags()
  • Existing test file canon/canon_test.go may have some coverage — check for overlap before writing
  • Create test file: canon/parse_test.go

Generated by /forge fill

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions