hindsight-core:store-testing
Safe HaskellNone
LanguageGHC2021

Test.Hindsight.Store

Description

Unified test suite API for event store backends

This module provides a single import point for backend test writers. It re-exports all test infrastructure, test suites, and utilities.

Typical Usage

import Test.Hindsight.Store

myStoreRunner :: EventStoreTestRunner MyBackend
myStoreRunner = EventStoreTestRunner { ... }

tests = testGroup "My Backend Tests"
  [ testGroup "Generic Tests" (genericEventStoreTests myStoreRunner)
  , testGroup "Multi-Instance Tests" (multiInstanceTests myStoreRunner)
  , testGroup "Stress Tests" (stressTests myStoreRunner)
  , propertyTests myStoreRunner
  , testGroup "Ordering Tests" (orderingTests myStoreRunner)
  ]
Synopsis

Test Infrastructure

data EventStoreTestRunner backend Source #

Test runner for event store tests

Constructors

EventStoreTestRunner 

Fields

  • withStore :: forall a. (BackendHandle backend -> IO a) -> IO ()

    For single-instance tests: provides one handle to the backend

  • withStores :: forall a. Int -> ([BackendHandle backend] -> IO a) -> IO ()

    For multi-instance tests: provides N handles to the same backend storage Simulates multiple processes accessing the same backend

Test Suite Composition

genericEventStoreTests :: (EventStore backend, StoreConstraints backend IO, Show (Cursor backend), Ord (Cursor backend)) => EventStoreTestRunner backend -> [TestTree] Source #

Common event store test cases split into focused test groups

multiInstanceTests :: (EventStore backend, StoreConstraints backend IO, Show (Cursor backend), Ord (Cursor backend)) => EventStoreTestRunner backend -> [TestTree] Source #

Multi-instance test cases (for backends that support cross-process subscriptions)

Individual Test Suites

basicTests :: (EventStore backend, StoreConstraints backend IO, Show (Cursor backend)) => EventStoreTestRunner backend -> [TestTree] Source #

Basic test suite for event store backends

consistencyTests :: (EventStore backend, StoreConstraints backend IO, Show (Cursor backend), Show (EventStoreError backend)) => EventStoreTestRunner backend -> [TestTree] Source #

Consistency test suite for event store backends

cursorTests :: (EventStore backend, StoreConstraints backend IO, Show (Cursor backend), Ord (Cursor backend)) => EventStoreTestRunner backend -> [TestTree] Source #

Per-stream cursor test suite for event store backends

streamVersionTests :: (EventStore backend, StoreConstraints backend IO) => EventStoreTestRunner backend -> [TestTree] Source #

Stream version test suite for event store backends

multiInstanceEventOrderingTests :: (EventStore backend, StoreConstraints backend IO, Show (Cursor backend), Ord (Cursor backend)) => EventStoreTestRunner backend -> [TestTree] Source #

Multi-instance ordering test suite for event store backends

orderingTests :: (EventStore backend, StoreConstraints backend IO, Show (Cursor backend)) => EventStoreTestRunner backend -> [TestTree] Source #

Backend-agnostic ordering test suite

propertyTests :: (EventStore backend, StoreConstraints backend IO, Show (Cursor backend)) => EventStoreTestRunner backend -> TestTree Source #

Backend-agnostic property-based tests

stressTests :: (EventStore backend, StoreConstraints backend IO) => EventStoreTestRunner backend -> [TestTree] Source #

Backend-agnostic stress test suite

Test Utilities