Skip to content

Commit

Permalink
Tidy
Browse files Browse the repository at this point in the history
  • Loading branch information
bartelink committed Oct 16, 2020
1 parent 0b44dd1 commit d4ed893
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 9 deletions.
4 changes: 2 additions & 2 deletions src/Equinox.CosmosStore/CosmosStore.fs
Original file line number Diff line number Diff line change
Expand Up @@ -1018,7 +1018,7 @@ module Internal =

/// Defines the policies in force regarding how to split up calls when loading Event Batches via queries
type QueryOptions
( /// Max Batches to request in query response. Defaults: 10.
( /// Max number of Batches to return per paged query response. Default: 10.
[<O; D(null)>]?defaultMaxItems : int,
/// Dynamic version of `defaultMaxItems`, allowing one to react to dynamic configuration changes. Default: use `defaultMaxItems` value.
[<O; D(null)>]?getDefaultMaxItems : unit -> int,
Expand Down Expand Up @@ -1403,7 +1403,7 @@ type EventsContext internal
/// Logger to write to - see https://github.com/serilog/serilog/wiki/Provided-Sinks for how to wire to your logger
log : Serilog.ILogger,
/// Optional maximum number of Store.Batch records to retrieve as a set (how many Events are placed therein is controlled by average batch size when appending events
/// Defaults to 10
/// Default: 10
[<Optional; DefaultParameterValue(null)>]?defaultMaxItems,
/// Alternate way of specifying defaultMaxItems that facilitates reading it from a cached dynamic configuration
[<Optional; DefaultParameterValue(null)>]?getDefaultMaxItems) =
Expand Down
11 changes: 4 additions & 7 deletions tests/Equinox.CosmosStore.Integration/CosmosCoreIntegration.fs
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,15 @@ type Tests(testOutputHelper) =
let (|TestStream|) (name: Guid) =
incr testIterations
sprintf "events-%O-%i" name !testIterations
let mkContextWithItemLimit log maxItems =
createPrimaryEventsContext log (Some maxItems)

let verifyRequestChargesMax rus =
let tripRequestCharges = [ for e, c in capture.RequestCharges -> sprintf "%A" e, c ]
test <@ float rus >= Seq.sum (Seq.map snd tripRequestCharges) @>

[<AutoData(SkipIfRequestedViaEnvironmentVariable="EQUINOX_INTEGRATION_SKIP_COSMOS")>]
let append (TestStream streamName) = Async.RunSynchronously <| async {
let ctx = createPrimaryEventsContext log (Some 10)
capture.Clear()
let ctx = createPrimaryEventsContext log (Some defaultQueryMaxItems)

let index = 0L
let! res = Events.append ctx streamName index <| TestEvents.Create(0,1)
Expand All @@ -60,7 +58,7 @@ type Tests(testOutputHelper) =
// 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 ctx = mkContextWithItemLimit log 10
let ctx = createPrimaryEventsContext log (Some defaultQueryMaxItems)

let index = 0L
let! res = Events.append ctx streamName index (TestEvents.Create(0,0)) |> Async.Catch
Expand Down Expand Up @@ -108,7 +106,6 @@ type Tests(testOutputHelper) =
capture.Clear()

let ctx = createPrimaryEventsContext log (Some 1)
let ctx = mkContextWithItemLimit log 1

let! pos = Events.getNextIndex ctx streamName
test <@ [EqxAct.TipNotFound] = capture.ExternalCalls @>
Expand Down Expand Up @@ -166,7 +163,7 @@ type Tests(testOutputHelper) =
[<AutoData(SkipIfRequestedViaEnvironmentVariable="EQUINOX_INTEGRATION_SKIP_COSMOS")>]
let ``append - fails on non-matching`` (TestStream streamName) = Async.RunSynchronously <| async {
capture.Clear()
let ctx = createPrimaryEventsContext log (Some 10)
let ctx = createPrimaryEventsContext log (Some defaultQueryMaxItems)

// Attempt to write, skipping Index 0
let! res = Events.append ctx streamName 1L <| TestEvents.Create(0,1)
Expand Down Expand Up @@ -313,7 +310,7 @@ type Tests(testOutputHelper) =

[<AutoData(SkipIfRequestedViaEnvironmentVariable="EQUINOX_INTEGRATION_SKIP_COSMOS")>]
let prune (TestStream streamName) = Async.RunSynchronously <| async {
let ctx = createPrimaryEventsContext log (Some 10)
let ctx = createPrimaryEventsContext log (Some defaultQueryMaxItems)
let! expected = add6EventsIn2Batches ctx streamName

// Trigger deletion of first batch
Expand Down

0 comments on commit d4ed893

Please sign in to comment.