Skip to content

test: add unit tests for canon/digest.go — Digest and PipelineDigest #13

@jpleva91

Description

@jpleva91

Problem

canon/digest.go has zero test coverage. Digest() and PipelineDigest() are critical for deterministic command fingerprinting — if these produce non-deterministic hashes, doom-loop detection and event deduplication break silently.

Acceptance Criteria

  • Test Digest() produces identical hashes for semantically equivalent commands (same tool/action/flags/args in different order)
  • Test Digest() produces different hashes for different commands
  • Test PipelineDigest() produces identical hashes for equivalent pipelines
  • Test PipelineDigest() produces different hashes for pipelines with different operators or segments
  • Test that flag ordering does not affect digest (flags are sorted)
  • Test empty command edge case
  • All tests pass with go test ./canon/...

Hints

  • File: canon/digest.go
  • Functions: Digest(cmd Command) string, PipelineDigest(p Pipeline) string
  • Types in canon/types.go: Command, Pipeline, Segment, ChainOp
  • Digest uses SHA-256, truncated to 16 hex chars
  • Create test file: canon/digest_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