Simplify EventModel test golden file management

Resolved 💬 1 comment Opened Jan 12, 2026 by randrag Closed Jan 12, 2026

Problem

Currently, EventModel test PUML golden files use descriptive names that include both the D-number and test description:

D185657 - Update provisional unit cost on docket line.puml

This causes issues when test descriptions change (e.g., renaming "provisional" to "estimated"):

  • Duplicate files are created with old and new names
  • Manual cleanup required to remove old files
  • The WIP/Golden folder comparison adds complexity

Proposed Changes

1. Use D-number only for PUML filenames

Name files using only their D-number:

D185657.puml

Benefits:

  • Renaming test descriptions doesn't create duplicate files
  • Simpler, consistent naming
  • The description is already in the test code and PUML title

2. Remove WIP folder - work directly in Golden

Current flow:

  1. Test generates PUML to WIP/ folder
  2. Test compares WIP content against Golden/ folder
  3. Test fails if mismatch
  4. Developer manually copies WIP to Golden

Proposed flow:

  1. Test generates/updates PUML directly in Golden/ folder
  2. Use git diff to review changes
  3. Commit when satisfied

Benefits:

  • Eliminates duplicate folder structure
  • Natural git workflow for reviewing changes
  • No manual copy step required

3. Don't fail tests on golden file changes

Currently tests fail with ContentsMismatch when PUML output differs from golden file.

Instead:

  • Always write the current output to the golden file
  • Use git to track and review changes
  • Tests should validate expected final state(s) via assertions, not file comparison

Benefits:

  • Tests focus on behavioral correctness, not output format
  • PUML changes from refactoring don't break CI
  • Developers review PUML changes in normal git diff workflow

4. Require state assertions in all EventModel tests

Each test should include explicit assertions checking the expected final state after commands execute. Example:

// Critical data assertion
let estimatedUnitCostLine1 =
    cs.CommandSessionResult.CacheState.get_sal_d__
    |> _.ToLatestStateM
    |> _.ToStateT_L
    |> List.head
    |> _.State
    |> fun stateU ->
        match stateU with
        | Docket.StateU.Draft dd ->
            dd.LineM.ToMapWithRank
            |> Map.find Docket.Lines.id_1
            |> fun (lineP, _rank) -> lineP.EstimatedUnitCostO
        | _ -> None
    |> Option.map _.UnwrappedToDecimal

test <@ estimatedUnitCostLine1 = Some 7M @>

Migration Path

  1. Rename all existing PUML files to D-number only format
  2. Update Runner.runWorkAndSaveDiagram to write directly to Golden folder
  3. Remove WIP folder comparison logic
  4. Remove GoldenFileCheckResult.IsSuccess assertions from tests
  5. Audit tests to ensure each has meaningful state assertions

Files Affected

  • p20.2.EventModels.Sales/ - Sales domain EventModel tests
  • p15.2.EventModels.Manufacturing/ - Manufacturing EventModel tests
  • p15.4.EventModels.Inventory/ - Inventory EventModel tests
  • p20.2.EventModels.Retail/ - Retail EventModel tests
  • EventModel test runner/infrastructure code

View original on GitHub ↗

This issue has 1 comment on GitHub. Read the full discussion on GitHub ↗