Skip to content

test(chronicle): negative append tests assert diagnostic strings, not failure modes #34

Description

@argen

Source: code-review of #30; nice-to-have, deferred at merge.

The negative test fixtures in tests/chronicle/append/bad-signatures.txt assert specific diagnostic substrings — e.g. "section 'Diagnosis' is not appendable for type 'hypothesis'". Any rewording of the die message will break the test even when the failure mode itself is unchanged.

Today the tests mostly exercise the message author's typing rather than the script's behaviour. Per Beck, Test-Driven Development: tests should fail for one reason.

Concrete proposal (two options, depending on intent):

  1. If diagnostic copy is itself the user contract (i.e., we want to guarantee it doesn't drift): document this explicitly in bad-signatures.txt with a comment so a future maintainer knows they're committing to the wording, not the failure class.

  2. If diagnostic copy is incidental (more likely): introduce error-class tags, e.g. emit [ERR_NOT_APPENDABLE] as a stable prefix on the stderr line and assert against the tag. Wording can then evolve without test churn.

Same pattern applies to the existing tests/chronicle/bad-signatures.txt for the validator — worth addressing both at once if we go with option 2.

Files:

  • tests/chronicle/append/bad-signatures.txt
  • tests/chronicle/bad-signatures.txt
  • scripts/chronicle.sh (the die ... call sites if we add tags)

Risk: low — refactor with the harness as the safety net.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions