test: fix date dependencies in cycle generator tests
- Add create_member_with_cycles helper that uses fixed 'today' date - Update tests to use explicit 'today:' option instead of Date.utc_today() - Prevents test failures when current date changes (e.g., in 2026+) - Tests now explicitly delete and regenerate cycles with fixed dates - Ensures consistent test behavior regardless of execution date
This commit is contained in:
parent
0b986db635
commit
f7fc1f4897
3 changed files with 216 additions and 91 deletions
|
|
@ -211,13 +211,18 @@ defmodule Mv.MembershipFees.MemberCycleIntegrationTest do
|
|||
initial_cycles = get_member_cycles(member.id)
|
||||
initial_count = length(initial_cycles)
|
||||
|
||||
# Manually trigger generation again
|
||||
{:ok, _} = Mv.MembershipFees.CycleGenerator.generate_cycles_for_member(member.id)
|
||||
# Use a fixed "today" date to avoid date dependency
|
||||
# Use a date far enough in the future to ensure all cycles are generated
|
||||
today = ~D[2025-12-31]
|
||||
|
||||
# Manually trigger generation again with fixed "today" date
|
||||
{:ok, _} =
|
||||
Mv.MembershipFees.CycleGenerator.generate_cycles_for_member(member.id, today: today)
|
||||
|
||||
final_cycles = get_member_cycles(member.id)
|
||||
final_count = length(final_cycles)
|
||||
|
||||
# Should have same number of cycles
|
||||
# Should have same number of cycles (idempotent)
|
||||
assert final_count == initial_count
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue