test(member-live): build date-filter property bounds without a reject-filter
The bound-pair generator filtered out ~1/4 of generated values, so unlucky seeds hit StreamData's FilterTooNarrowError under full property runs. Construct an at-least-one-bound-set pair directly instead, preserving the exact domain with no rejection.
This commit is contained in:
parent
655fd80524
commit
cb54c2c46e
1 changed files with 18 additions and 11 deletions
|
|
@ -20,11 +20,12 @@ defmodule MvWeb.MemberLive.Index.DateFilterPropertyTest do
|
|||
|
||||
# Generators -----------------------------------------------------------
|
||||
|
||||
defp date_gen do
|
||||
map(integer(-3650..3650), &Date.add(~D[2000-01-01], &1))
|
||||
end
|
||||
|
||||
defp optional_date_gen do
|
||||
one_of([
|
||||
constant(nil),
|
||||
map(integer(-3650..3650), &Date.add(~D[2000-01-01], &1))
|
||||
])
|
||||
one_of([constant(nil), date_gen()])
|
||||
end
|
||||
|
||||
defp exit_date_mode_gen do
|
||||
|
|
@ -57,19 +58,25 @@ defmodule MvWeb.MemberLive.Index.DateFilterPropertyTest do
|
|||
|
||||
# Property -------------------------------------------------------------
|
||||
|
||||
# Generates a {from, to} pair with at least one bound set. Built by construction
|
||||
# (pick which bounds are set, then generate the required dates) rather than by
|
||||
# filtering out the both-nil case, so StreamData never rejects values and cannot
|
||||
# raise FilterTooNarrowError on unlucky seeds.
|
||||
defp bound_pair_with_at_least_one_set_gen do
|
||||
gen all(
|
||||
from <- optional_date_gen(),
|
||||
to <- optional_date_gen(),
|
||||
from != nil or to != nil
|
||||
which <- member_of([:from_only, :to_only, :both]),
|
||||
date_a <- date_gen(),
|
||||
date_b <- date_gen()
|
||||
) do
|
||||
{from, to}
|
||||
case which do
|
||||
:from_only -> {date_a, nil}
|
||||
:to_only -> {nil, date_a}
|
||||
:both -> {date_a, date_b}
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
defp value_date_gen do
|
||||
map(integer(-3650..3650), &Date.add(~D[2000-01-01], &1))
|
||||
end
|
||||
defp value_date_gen, do: date_gen()
|
||||
|
||||
# Property -------------------------------------------------------------
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue