Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cleanup: Add more alert factories for use in SystemStatus.SubwayTests #2347

Merged
merged 2 commits into from
Feb 13, 2025

Conversation

joshlarson
Copy link
Contributor

@joshlarson joshlarson force-pushed the jdl/system-status-alert-factory branch from 5d53205 to f852999 Compare January 30, 2025 16:15
Base automatically changed from jdl/system-status-flowchart to main February 5, 2025 14:24
@joshlarson joshlarson force-pushed the jdl/system-status-alert-factory branch 3 times, most recently from f587772 to 8bf0570 Compare February 7, 2025 19:04
@@ -4,7 +4,7 @@ defmodule Dotcom.SystemStatus.SubwayTest do

alias Dotcom.SystemStatus.Alerts
alias Dotcom.SystemStatus.Subway
alias Test.Support.Factories.Alerts.Alert
import Test.Support.Factories.Alerts.Alert
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

import and alias statements are separated and alphabetized. but, i wouldn't import here because it is difficult to know what build references

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah - it got mildly annoying to keep calling Alert.<whatever>, but that is better than the bizarre "Where did build come from setup that using import here provides.

Comment on lines +55 to +63
defp time_before(time) do
between(Timex.beginning_of_day(time), time)
end

# Returns a random time during the day today after the time provided.
defp time_after(time) do
between(time, Timex.end_of_day(time))
end
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these are general enough to be moved somewhere else

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thoughts on where, specifically? A DateTime factory?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💀 Well, now main has a Test.Support.Generators.DateTime.random_time_range_date_time({start, stop}) function that returns a time between start & stop that I suppose would work here

end

def with_high_priority_effect(alert) do
%{alert | effect: Faker.Util.pick(Dotcom.SystemStatus.Alerts.service_effects())}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why are we calling the factory priority_effect when the function is called service_effects?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Old naming scheme meet new naming scheme!

Would fix this, but it made more sense to delete instead ❌

Comment on lines 37 to 40
InformedEntitySet.build(:informed_entity_set,
route: route_id,
entities: [
InformedEntity.build(:informed_entity, route: route_id)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i would move this to the informed entity set factory since they need to be in agreement

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done, I think!

@joshlarson joshlarson force-pushed the jdl/system-status-alert-factory branch from cd4e54e to 9798a8e Compare February 8, 2025 20:59
@joshlarson joshlarson force-pushed the jdl/system-status-alert-factory branch from 4a97d25 to e58865d Compare February 12, 2025 01:00
@joshlarson joshlarson force-pushed the jdl/system-status-alert-factory branch from e58865d to 9579171 Compare February 12, 2025 01:01
@joshlarson joshlarson marked this pull request as ready for review February 12, 2025 01:01
@joshlarson joshlarson requested a review from a team as a code owner February 12, 2025 01:01
Copy link
Collaborator

@thecristen thecristen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like the additional factories.

...in order to make sure that the informed entity set is consistent,
since new/1 does some processing that gets bypassed by the factory
@thecristen thecristen merged commit 75829cb into main Feb 13, 2025
17 checks passed
@thecristen thecristen deleted the jdl/system-status-alert-factory branch February 13, 2025 15:37
thecristen pushed a commit that referenced this pull request Feb 13, 2025
…#2347)

* cleanup: Add more alert factories for use in SystemStatus.SubwayTests

* fix: Use InformedEntitySet.new/1 rather than its factory

...in order to make sure that the informed entity set is consistent,
since new/1 does some processing that gets bypassed by the factory
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants