Closed michaeljones closed 4 years ago
I've been using Phauxth on my project and one of the auto-generated session tests started failing today. This one:
https://github.com/riverrun/phauxth_installer/blob/master/phauxth_new/templates/sessions_test.exs#L18-L21
And it seems that it is possibly because of this line:
https://github.com/riverrun/phauxth_installer/blob/master/phauxth_new/templates/sessions.ex#L18
I'm a beginner but it seems from some reading that it is preferable to use DateTime.compare for dates rather than > as the normal comparison operators do date-unaware struct comparisons on the DateTime structs and produce confusing results.
DateTime.compare
>
I guess it is possible to write this as:
Enum.filter(sessions, &(DateTime.compare(&1.expires_at, DateTime.utc_now()) == :gt))
Instead? Or possibly move the expiry check into an Ecto query?
I get this too. I'll whip up a quick PR.
See https://github.com/riverrun/phauxth_installer/pull/16
I've been using Phauxth on my project and one of the auto-generated session tests started failing today. This one:
https://github.com/riverrun/phauxth_installer/blob/master/phauxth_new/templates/sessions_test.exs#L18-L21
And it seems that it is possibly because of this line:
https://github.com/riverrun/phauxth_installer/blob/master/phauxth_new/templates/sessions.ex#L18
I'm a beginner but it seems from some reading that it is preferable to use
DateTime.compare
for dates rather than>
as the normal comparison operators do date-unaware struct comparisons on the DateTime structs and produce confusing results.I guess it is possible to write this as:
Instead? Or possibly move the expiry check into an Ecto query?