Skip to content

Commit

Permalink
chore: upgrade FsCheck (#397)
Browse files Browse the repository at this point in the history
  • Loading branch information
nordfjord authored Jun 11, 2023
1 parent 1e2a3a8 commit aab44ef
Show file tree
Hide file tree
Showing 22 changed files with 76 additions and 63 deletions.
2 changes: 1 addition & 1 deletion samples/Store/Domain.Tests/Domain.Tests.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="FsCheck.xUnit" Version="2.16.4" />
<PackageReference Include="FsCheck.xUnit" Version="3.0.0-beta2" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.3.1" />
<PackageReference Include="xunit" Version="2.4.2" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5">
Expand Down
5 changes: 4 additions & 1 deletion samples/Store/Domain.Tests/Infrastructure.fs
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,15 @@
module Samples.Store.Domain.Tests.Infrastructure

open Domain
open FsCheck
open FsCheck.FSharp
open FSharp.UMX
open Swensen.Unquote
open System
open global.Xunit

module Arb =
let generate<'t> = ArbMap.defaults |> ArbMap.generate<'t>

type FsCheckGenerators =
static member SkuId = Arb.generate |> Gen.map SkuId |> Arb.fromGen

Expand Down
10 changes: 5 additions & 5 deletions samples/Store/Integration/CartIntegration.fs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ type Tests(testOutputHelper) =
}

[<AutoData>]
let ``Can roundtrip in Memory, correctly folding the events`` args = Async.RunSynchronously <| async {
let ``Can roundtrip in Memory, correctly folding the events`` args = async {
let store = createMemoryStore ()
let service = createServiceMemory log store
do! act service args
Expand All @@ -59,13 +59,13 @@ type Tests(testOutputHelper) =
return Cart.create (createCategory context |> Decider.resolve log) }

[<AutoData(SkipIfRequestedViaEnvironmentVariable="EQUINOX_INTEGRATION_SKIP_EVENTSTORE")>]
let ``Can roundtrip against EventStore, correctly folding the events without compaction semantics`` args = Async.RunSynchronously <| async {
let ``Can roundtrip against EventStore, correctly folding the events without compaction semantics`` args = async {
let! service = arrangeEs connectToLocalEventStoreNode createContext categoryGesStreamWithoutCustomAccessStrategy
do! act service args
}

[<AutoData(SkipIfRequestedViaEnvironmentVariable="EQUINOX_INTEGRATION_SKIP_EVENTSTORE")>]
let ``Can roundtrip against EventStore, correctly folding the events with RollingSnapshots`` args = Async.RunSynchronously <| async {
let ``Can roundtrip against EventStore, correctly folding the events with RollingSnapshots`` args = async {
let! service = arrangeEs connectToLocalEventStoreNode createContext categoryGesStreamWithRollingSnapshots
do! act service args
}
Expand All @@ -75,13 +75,13 @@ type Tests(testOutputHelper) =
Cart.create (createCategory context |> Decider.resolve log)

[<AutoData(SkipIfRequestedViaEnvironmentVariable="EQUINOX_INTEGRATION_SKIP_COSMOS")>]
let ``Can roundtrip against Cosmos, correctly folding the events without custom access strategy`` args = Async.RunSynchronously <| async {
let ``Can roundtrip against Cosmos, correctly folding the events without custom access strategy`` args = async {
let service = arrangeCosmos createPrimaryContext categoryCosmosStreamWithoutCustomAccessStrategy
do! act service args
}

[<AutoData(SkipIfRequestedViaEnvironmentVariable="EQUINOX_INTEGRATION_SKIP_COSMOS")>]
let ``Can roundtrip against Cosmos, correctly folding the events with With Snapshotting`` args = Async.RunSynchronously <| async {
let ``Can roundtrip against Cosmos, correctly folding the events with With Snapshotting`` args = async {
let service = arrangeCosmos createPrimaryContext categoryCosmosStreamWithSnapshotStrategy
do! act service args
}
12 changes: 6 additions & 6 deletions samples/Store/Integration/ContactPreferencesIntegration.fs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ type Tests(testOutputHelper) =
test <@ value = actual @> }

[<AutoData>]
let ``Can roundtrip in Memory, correctly folding the events`` args = Async.RunSynchronously <| async {
let ``Can roundtrip in Memory, correctly folding the events`` args = async {
let store = createMemoryStore ()
let service = createServiceMemory log store
do! act service args
Expand All @@ -51,13 +51,13 @@ type Tests(testOutputHelper) =
return ContactPreferences.create (createCategory context |> Decider.resolve log) }

[<AutoData(SkipIfRequestedViaEnvironmentVariable="EQUINOX_INTEGRATION_SKIP_EVENTSTORE")>]
let ``Can roundtrip against EventStore, correctly folding the events with normal semantics`` args = Async.RunSynchronously <| async {
let ``Can roundtrip against EventStore, correctly folding the events with normal semantics`` args = async {
let! service = arrangeEs connectToLocalEventStoreNode createContext categoryGesWithoutAccessStrategy
do! act service args
}

[<AutoData(SkipIfRequestedViaEnvironmentVariable="EQUINOX_INTEGRATION_SKIP_EVENTSTORE")>]
let ``Can roundtrip against EventStore, correctly folding the events with compaction semantics`` args = Async.RunSynchronously <| async {
let ``Can roundtrip against EventStore, correctly folding the events with compaction semantics`` args = async {
let! service = arrangeEs connectToLocalEventStoreNode createContext categoryGesWithOptimizedStorageSemantics
do! act service args
}
Expand All @@ -67,19 +67,19 @@ type Tests(testOutputHelper) =
ContactPreferences.create (createCategory context |> Decider.resolve log)

[<AutoData(SkipIfRequestedViaEnvironmentVariable="EQUINOX_INTEGRATION_SKIP_COSMOS")>]
let ``Can roundtrip against Cosmos, correctly folding the events with Unoptimized semantics`` args = Async.RunSynchronously <| async {
let ``Can roundtrip against Cosmos, correctly folding the events with Unoptimized semantics`` args = async {
let service = arrangeCosmos createPrimaryContext categoryCosmosUnoptimized defaultQueryMaxItems
do! act service args
}

[<AutoData(SkipIfRequestedViaEnvironmentVariable="EQUINOX_INTEGRATION_SKIP_COSMOS")>]
let ``Can roundtrip against Cosmos, correctly folding the events with LatestKnownEvent semantics`` args = Async.RunSynchronously <| async {
let ``Can roundtrip against Cosmos, correctly folding the events with LatestKnownEvent semantics`` args = async {
let service = arrangeCosmos createPrimaryContext categoryCosmosWithLatestKnownEventSemantics 1
do! act service args
}

[<AutoData(SkipIfRequestedViaEnvironmentVariable="EQUINOX_INTEGRATION_SKIP_COSMOS")>]
let ``Can roundtrip against Cosmos, correctly folding the events with RollingUnfold semantics`` args = Async.RunSynchronously <| async {
let ``Can roundtrip against Cosmos, correctly folding the events with RollingUnfold semantics`` args = async {
let service = arrangeCosmos createPrimaryContext categoryCosmosRollingUnfolds defaultQueryMaxItems
do! act service args
}
10 changes: 5 additions & 5 deletions samples/Store/Integration/FavoritesIntegration.fs
Original file line number Diff line number Diff line change
Expand Up @@ -65,15 +65,15 @@ type Tests(testOutputHelper) =
return version, items }

[<AutoData>]
let ``Can roundtrip in Memory, correctly folding the events`` args = Async.RunSynchronously <| async {
let ``Can roundtrip in Memory, correctly folding the events`` args = async {
let store = createMemoryStore ()
let service = createServiceMemory log store
let! version, items = act service args
version =! items.LongLength
}

[<AutoData(SkipIfRequestedViaEnvironmentVariable="EQUINOX_INTEGRATION_SKIP_EVENTSTORE")>]
let ``Can roundtrip against EventStore, correctly folding the events`` args = Async.RunSynchronously <| async {
let ``Can roundtrip against EventStore, correctly folding the events`` args = async {
let client = connectToLocalEventStoreNode log
let context = createContext client defaultBatchSize
let service = createServiceGes log context
Expand All @@ -82,7 +82,7 @@ type Tests(testOutputHelper) =
}

[<AutoData(SkipIfRequestedViaEnvironmentVariable="EQUINOX_INTEGRATION_SKIP_COSMOS")>]
let ``Can roundtrip against Cosmos, correctly folding the events with caching`` (clientId, cmd) = Async.RunSynchronously <| async {
let ``Can roundtrip against Cosmos, correctly folding the events with caching`` (clientId, cmd) = async {
let context = createPrimaryContext log defaultQueryMaxItems
let service = createServiceCosmosUnoptimizedButCached log context
let clientId = clientId () // generate a fresh one per test so repeated runs start from a stable base
Expand All @@ -100,15 +100,15 @@ type Tests(testOutputHelper) =
rereadVersion2 =! items.LongLength
}
[<AutoData(SkipIfRequestedViaEnvironmentVariable="EQUINOX_INTEGRATION_SKIP_COSMOS")>]
let ``Can roundtrip against Cosmos, correctly folding the events`` args = Async.RunSynchronously <| async {
let ``Can roundtrip against Cosmos, correctly folding the events`` args = async {
let context = createPrimaryContext log defaultQueryMaxItems
let service = createServiceCosmosSnapshotsUncached log context
let! version, items = act service args
version =! items.LongLength
}

[<AutoData(SkipIfRequestedViaEnvironmentVariable="EQUINOX_INTEGRATION_SKIP_COSMOS")>]
let ``Can roundtrip against Cosmos, correctly folding the events with rolling unfolds`` args = Async.RunSynchronously <| async {
let ``Can roundtrip against Cosmos, correctly folding the events with rolling unfolds`` args = async {
let context = createPrimaryContext log defaultQueryMaxItems
let service = createServiceCosmosRollingStateUncached log context
let! version, _items = act service args
Expand Down
5 changes: 4 additions & 1 deletion samples/Store/Integration/Infrastructure.fs
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
namespace global

open Domain
open FsCheck
open FsCheck.FSharp
open System

module Arb =
let generate<'t> = ArbMap.defaults |> ArbMap.generate<'t>

type FsCheckGenerators =
static member SkuId = Arb.generate |> Gen.map SkuId |> Arb.fromGen
static member ContactPreferencesId =
Expand Down
2 changes: 1 addition & 1 deletion samples/Store/Integration/Integration.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="FsCheck.xUnit" Version="2.16.4" />
<PackageReference Include="FsCheck.xUnit" Version="3.0.0-beta2" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.3.1" />
<PackageReference Include="Serilog.Sinks.Seq" Version="5.2.0" />
<PackageReference Include="unquote" Version="6.1.0" />
Expand Down
4 changes: 2 additions & 2 deletions samples/Store/Integration/LogIntegration.fs
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ type Tests(testOutputHelper) =

// Protip: Debug this test to view standard metrics rendering
[<AutoData(SkipIfRequestedViaEnvironmentVariable="EQUINOX_INTEGRATION_SKIP_EVENTSTORE")>]
let ``Can roundtrip against EventStore, hooking, extracting and substituting metrics in the logging information`` (ctx, skuId) = Async.RunSynchronously <| async {
let ``Can roundtrip against EventStore, hooking, extracting and substituting metrics in the logging information`` (ctx, skuId) = async {
let batchSize = defaultBatchSize
let buffer = ConcurrentQueue<string>()
let log = createLoggerWithMetricsExtraction buffer.Enqueue
Expand All @@ -116,7 +116,7 @@ type Tests(testOutputHelper) =
}

[<AutoData(SkipIfRequestedViaEnvironmentVariable="EQUINOX_INTEGRATION_SKIP_COSMOS")>]
let ``Can roundtrip against Cosmos, hooking, extracting and substituting metrics in the logging information`` (ctx, skuId) = Async.RunSynchronously <| async {
let ``Can roundtrip against Cosmos, hooking, extracting and substituting metrics in the logging information`` (ctx, skuId) = async {
let queryMaxItems = defaultQueryMaxItems
let buffer = ConcurrentQueue<string>()
let log = createLoggerWithMetricsExtraction buffer.Enqueue
Expand Down
4 changes: 2 additions & 2 deletions tests/Equinox.CosmosStore.Integration/AccessStrategies.fs
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,8 @@ module SequenceCheck =
createCategoryUnoptimized Events.codec Fold.initial Fold.fold (context, cache) |> Equinox.Decider.resolve log |> create

module Props =

open FsCheck
open FsCheck.FSharp
type EventsInTip = EventsInTip of int
type EventCount = EventCount of int
type GapGen =
Expand Down Expand Up @@ -109,7 +109,7 @@ type UnoptimizedTipReadingCorrectness(testOutputHelper) =
/// This test compares the experiences of cached and uncached paths to reading the same data within a given stream
/// This is in order to shake out bugs and/or variation induced by the presence of stale state in the cache entry
[<Props.FsCheck(SkipIfRequestedViaEnvironmentVariable="EQUINOX_INTEGRATION_SKIP_COSMOS")>]
let ``Can sync with competing writer with and without cache`` (instanceId, contextArgs, firstIsCached, Props.EventCount count1, Props.EventCount count2) = Async.RunSynchronously <| async {
let ``Can sync with competing writer with and without cache`` (instanceId, contextArgs, firstIsCached, Props.EventCount count1, Props.EventCount count2) = async {
let context = createContext contextArgs
let service1, service2 =
let uncached = SequenceCheck.Config.createUncached log context
Expand Down
24 changes: 12 additions & 12 deletions tests/Equinox.CosmosStore.Integration/CosmosCoreIntegration.fs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ type Tests(testOutputHelper) =
test <@ float rus >= Seq.sum (Seq.map snd tripRequestCharges) @>

[<AutoData(MaxTest = 2, SkipIfRequestedViaEnvironmentVariable="EQUINOX_INTEGRATION_SKIP_COSMOS")>]
let append (eventsInTip, TestStream streamName) = Async.RunSynchronously <| async {
let append (eventsInTip, TestStream streamName) = async {
capture.Clear()
let ctx = createPrimaryEventsContext log defaultQueryMaxItems (if eventsInTip then 1 else 0)

Expand All @@ -57,7 +57,7 @@ type Tests(testOutputHelper) =
// It's conceivable that in the future we might allow zero-length batches as long as a sync mechanism leveraging the etags and unfolds update mechanisms
// As it stands with the NoTipEvents stored proc, permitting empty batches a) yields an invalid state b) provides no conceivable benefit
[<AutoData(SkipIfRequestedViaEnvironmentVariable="EQUINOX_INTEGRATION_SKIP_COSMOS")>]
let ``append Throws when passed an empty batch`` (TestStream streamName) = Async.RunSynchronously <| async {
let ``append Throws when passed an empty batch`` (TestStream streamName) = async {
let ctx = createPrimaryEventsContext log defaultQueryMaxItems 10

let index = 0L
Expand Down Expand Up @@ -100,7 +100,7 @@ type Tests(testOutputHelper) =
let verifyCorrectEvents = verifyCorrectEventsEx Direction.Forward
[<AutoData(MaxTest = 2, SkipIfRequestedViaEnvironmentVariable="EQUINOX_INTEGRATION_SKIP_COSMOS")>]
let ``appendAtEnd and getNextIndex`` (eventsInTip, extras, TestStream streamName) = Async.RunSynchronously <| async {
let ``appendAtEnd and getNextIndex`` (eventsInTip, extras, TestStream streamName) = async {
// If a fail triggers a rerun, we need to dump the previous log entries captured
capture.Clear()
Expand Down Expand Up @@ -163,7 +163,7 @@ type Tests(testOutputHelper) =
}
[<AutoData(MaxTest = 2, SkipIfRequestedViaEnvironmentVariable="EQUINOX_INTEGRATION_SKIP_COSMOS")>]
let ``append - fails on non-matching`` (eventsInTip, TestStream streamName) = Async.RunSynchronously <| async {
let ``append - fails on non-matching`` (eventsInTip, TestStream streamName) = async {
capture.Clear()
let ctx = createPrimaryEventsContext log 10 (if eventsInTip then 1 else 0)
Expand Down Expand Up @@ -201,7 +201,7 @@ type Tests(testOutputHelper) =
(* Forward *)
[<AutoData(MaxTest = 2, SkipIfRequestedViaEnvironmentVariable="EQUINOX_INTEGRATION_SKIP_COSMOS")>]
let get (eventsInTip, TestStream streamName) = Async.RunSynchronously <| async {
let get (eventsInTip, TestStream streamName) = async {
let ctx = createPrimaryEventsContext log 3 (if eventsInTip then 10 else 0)
// We're going to ignore the first, to prove we can
Expand All @@ -218,7 +218,7 @@ type Tests(testOutputHelper) =
}
[<AutoData(MaxTest = 2, SkipIfRequestedViaEnvironmentVariable="EQUINOX_INTEGRATION_SKIP_COSMOS")>]
let ``get in 2 batches`` (eventsInTip, TestStream streamName) = Async.RunSynchronously <| async {
let ``get in 2 batches`` (eventsInTip, TestStream streamName) = async {
let ctx = createPrimaryEventsContext log 1 (if eventsInTip then 1 else 0)
let! expected = add6EventsIn2BatchesEx ctx streamName 2
Expand All @@ -234,7 +234,7 @@ type Tests(testOutputHelper) =
}
[<AutoData(MaxTest = 2, SkipIfRequestedViaEnvironmentVariable="EQUINOX_INTEGRATION_SKIP_COSMOS")>]
let ``get Lazy`` (eventsInTip, TestStream streamName) = Async.RunSynchronously <| async {
let ``get Lazy`` (eventsInTip, TestStream streamName) = async {
let ctx = createPrimaryEventsContext log 1 (if eventsInTip then 3 else 0)
let! expected = add6EventsIn2BatchesEx ctx streamName 4
Expand All @@ -257,7 +257,7 @@ type Tests(testOutputHelper) =
(* Backward *)
[<AutoData(MaxTest = 2, SkipIfRequestedViaEnvironmentVariable="EQUINOX_INTEGRATION_SKIP_COSMOS")>]
let getBackwards (eventsInTip, TestStream streamName) = Async.RunSynchronously <| async {
let getBackwards (eventsInTip, TestStream streamName) = async {
let ctx = createPrimaryEventsContext log 1 (if eventsInTip then 1 else 0)
let! expected = add6EventsIn2Batches ctx streamName
Expand All @@ -274,7 +274,7 @@ type Tests(testOutputHelper) =
}
[<AutoData(MaxTest = 2, SkipIfRequestedViaEnvironmentVariable="EQUINOX_INTEGRATION_SKIP_COSMOS")>]
let ``getBackwards in 2 batches`` (eventsInTip, TestStream streamName) = Async.RunSynchronously <| async {
let ``getBackwards in 2 batches`` (eventsInTip, TestStream streamName) = async {
let ctx = createPrimaryEventsContext log 1 (if eventsInTip then 1 else 0)
let! expected = add6EventsIn2BatchesEx ctx streamName 2
Expand All @@ -291,7 +291,7 @@ type Tests(testOutputHelper) =
}
[<AutoData(MaxTest = 2, SkipIfRequestedViaEnvironmentVariable="EQUINOX_INTEGRATION_SKIP_COSMOS")>]
let ``getBackwards Lazy`` (eventsInTip, TestStream streamName) = Async.RunSynchronously <| async {
let ``getBackwards Lazy`` (eventsInTip, TestStream streamName) = async {
let ctx = createPrimaryEventsContext log 1 (if eventsInTip then 3 else 0)
let! expected = add6EventsIn2BatchesEx ctx streamName 4
Expand Down Expand Up @@ -321,7 +321,7 @@ type Tests(testOutputHelper) =
(* Prune *)
[<AutoData(MaxTest = 2, SkipIfRequestedViaEnvironmentVariable="EQUINOX_INTEGRATION_SKIP_COSMOS")>]
let prune (eventsInTip, TestStream streamName) = Async.RunSynchronously <| async {
let prune (eventsInTip, TestStream streamName) = async {
let ctx, ctxUnsafe = createPrimaryEventsContextWithUnsafe log 10 (if eventsInTip then 3 else 0)
let! expected = add6EventsIn2BatchesEx ctx streamName 4
Expand Down Expand Up @@ -387,7 +387,7 @@ type Tests(testOutputHelper) =
(* Fallback *)
[<AutoData(MaxTest = 2, SkipIfRequestedViaEnvironmentVariable="EQUINOX_INTEGRATION_SKIP_COSMOS")>]
let fallback (eventsInTip, TestStream streamName) = Async.RunSynchronously <| async {
let fallback (eventsInTip, TestStream streamName) = async {
let ctx1, ctx1Unsafe = createPrimaryEventsContextWithUnsafe log 10 (if eventsInTip then 3 else 0)
let ctx2 = createArchiveEventsContext log defaultQueryMaxItems
let ctx12 = createFallbackEventsContext log defaultQueryMaxItems
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
namespace global

open Domain
open FsCheck
open FsCheck.FSharp
open System

module Arb =
let generate<'t> = ArbMap.defaults |> ArbMap.generate<'t>

type FsCheckGenerators =
static member SkuId = Arb.generate |> Gen.map SkuId |> Arb.fromGen
static member ContactPreferencesId =
Expand Down
Loading

0 comments on commit aab44ef

Please sign in to comment.