Remove fluent StreamWrites API, add GWT testing helpers #241

Closed
opened 2025-12-28 19:59:06 -08:00 by jwilger · 0 comments
jwilger commented 2025-12-28 19:59:06 -08:00 (Migrated from github.com)

Background

The StreamWrites fluent builder API (with_stream, with_event, build) was added to make test setup more pleasant. However, it creates a dual-API pattern that is confusing.

Changes

  1. Remove fluent API from StreamWrites since it is internal code anyway
  2. Add GWT testing helpers to eventcore-testing crate

Desired Testing Ergonomics

// Given the following events on stream A and B
let scenario = TestScenario::new()
    .given_events("account-123", vec![
        MoneyDeposited { amount: 100 },
        MoneyWithdrawn { amount: 50 },
    ])
    .given_events("account-456", vec![
        MoneyDeposited { amount: 200 },
    ]);

// When command is executed
scenario.when(TransferMoney { from: "account-123", to: "account-456", amount: 25 });

// Then I see the following new events
scenario.then_events("account-123", vec![
    MoneyWithdrawn { amount: 25 },
]);
scenario.then_events("account-456", vec![
    MoneyDeposited { amount: 25 },
]);

Acceptance Criteria

  • Fluent API removed from StreamWrites
  • GWT testing helpers added to eventcore-testing
  • All existing tests pass (refactored to use new helpers where appropriate)
  • Behavior preserved

Migrated from beads issue: eventcore-945

## Background The StreamWrites fluent builder API (with_stream, with_event, build) was added to make test setup more pleasant. However, it creates a dual-API pattern that is confusing. ## Changes 1. **Remove fluent API** from StreamWrites since it is internal code anyway 2. **Add GWT testing helpers** to eventcore-testing crate ## Desired Testing Ergonomics ```rust // Given the following events on stream A and B let scenario = TestScenario::new() .given_events("account-123", vec![ MoneyDeposited { amount: 100 }, MoneyWithdrawn { amount: 50 }, ]) .given_events("account-456", vec![ MoneyDeposited { amount: 200 }, ]); // When command is executed scenario.when(TransferMoney { from: "account-123", to: "account-456", amount: 25 }); // Then I see the following new events scenario.then_events("account-123", vec![ MoneyWithdrawn { amount: 25 }, ]); scenario.then_events("account-456", vec![ MoneyDeposited { amount: 25 }, ]); ``` ## Acceptance Criteria - [ ] Fluent API removed from StreamWrites - [ ] GWT testing helpers added to eventcore-testing - [ ] All existing tests pass (refactored to use new helpers where appropriate) - [ ] Behavior preserved --- *Migrated from beads issue: eventcore-945*
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
jwilger/eventcore#241
No description provided.