[Issue #3] Add unit tests for EventStore interface implementations #32

Merged
HugoNijhuis merged 1 commits from issue-3-eventstore-tests into main 2026-01-09 16:29:33 +00:00
Owner

Summary

  • Add comprehensive unit tests for InMemoryEventStore
  • Fix thread safety by adding mutex protection to InMemoryEventStore

Changes

  • Add store/memory_test.go with 30+ test cases covering all acceptance criteria
  • Add sync.RWMutex to InMemoryEventStore for concurrent access safety
  • Tests verify: SaveEvent persistence, GetEvents ordering and filtering, GetLatestVersion correctness, non-existent actor handling, concurrent access safety

Test Coverage

  • SaveEvent: single event, multiple events, multiple actors, field preservation
  • GetEvents: retrieval order, fromVersion filtering, edge cases
  • GetLatestVersion: correct version, updates after new events, version edge cases
  • Non-existent actors: returns empty slice/zero version without error
  • Concurrent access: race detector verified with 100 goroutines

Closes #3

## Summary - Add comprehensive unit tests for InMemoryEventStore - Fix thread safety by adding mutex protection to InMemoryEventStore ## Changes - Add `store/memory_test.go` with 30+ test cases covering all acceptance criteria - Add `sync.RWMutex` to InMemoryEventStore for concurrent access safety - Tests verify: SaveEvent persistence, GetEvents ordering and filtering, GetLatestVersion correctness, non-existent actor handling, concurrent access safety ## Test Coverage - SaveEvent: single event, multiple events, multiple actors, field preservation - GetEvents: retrieval order, fromVersion filtering, edge cases - GetLatestVersion: correct version, updates after new events, version edge cases - Non-existent actors: returns empty slice/zero version without error - Concurrent access: race detector verified with 100 goroutines Closes #3
HugoNijhuis added 1 commit 2026-01-09 16:14:35 +00:00
Add comprehensive unit tests for InMemoryEventStore
All checks were successful
CI / build (pull_request) Successful in 15s
CI / build (push) Successful in 15s
032fda41ce
- Test SaveEvent persists events correctly (single, multiple, multi-actor)
- Test GetEvents retrieves events in insertion order
- Test GetEvents with fromVersion filtering
- Test GetLatestVersion returns correct version
- Test behavior with non-existent actor IDs (returns empty/zero)
- Test concurrent access safety with race detector
- Add mutex protection to InMemoryEventStore for thread safety

Closes #3

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Author
Owner

Code Review - Approved

Excellent PR with comprehensive test coverage and proper thread safety implementation.

Highlights

  • 30+ well-structured tests covering all EventStore methods
  • Good use of sync.RWMutex for concurrent access safety
  • Thorough edge case testing (MaxInt64, empty store, special actor IDs)
  • Includes benchmarks for performance tracking
  • Race detector verified with 100 goroutines

Note

PR #31 (SnapshotStore tests) will need to rebase onto this and add the same mutex protection to SaveSnapshot/GetLatestSnapshot methods.

LGTM - ready to merge.

## Code Review - Approved Excellent PR with comprehensive test coverage and proper thread safety implementation. ### Highlights - 30+ well-structured tests covering all EventStore methods - Good use of `sync.RWMutex` for concurrent access safety - Thorough edge case testing (MaxInt64, empty store, special actor IDs) - Includes benchmarks for performance tracking - Race detector verified with 100 goroutines ### Note PR #31 (SnapshotStore tests) will need to rebase onto this and add the same mutex protection to `SaveSnapshot`/`GetLatestSnapshot` methods. LGTM - ready to merge.
HugoNijhuis merged commit 032fda41ce into main 2026-01-09 16:29:33 +00:00
Sign in to join this conversation.
No Reviewers
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: flowmade-one/aether#32