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

feat(OpenTripPlannerClient.Error): more detailed erroring #1

Merged
merged 7 commits into from
Dec 3, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 26 additions & 1 deletion test/support/factory.ex
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ if Code.ensure_loaded?(ExMachina) and Code.ensure_loaded?(Faker) do

import Faker.Random.Elixir, only: [random_uniform: 0]

alias OpenTripPlannerClient.PlanParams
alias OpenTripPlannerClient.{Plan, PlanParams}

alias OpenTripPlannerClient.Schema.{
Agency,
Expand All @@ -24,6 +24,31 @@ if Code.ensure_loaded?(ExMachina) and Code.ensure_loaded?(Faker) do
Trip
}

def plan_factory do
%Plan{
date: Faker.DateTime.forward(2),
itineraries: __MODULE__.build_list(3, :itinerary),
routing_errors: Faker.Util.pick([__MODULE__.build_list(1, :routing_error), []]),
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 split out a plan_with_errors factory from a plan_factory. I would be surprised if I went build(:plan) and got a plan that had errors.

search_window_used: 3600
}
end

def routing_error_factory do
%{
code:
Faker.Util.pick([
"NO_TRANSIT_CONNECTION",
"NO_TRANSIT_CONNECTION_IN_SEARCH_WINDOW",
"OUTSIDE_SERVICE_PERIOD",
"OUTSIDE_BOUNDS",
"LOCATION_NOT_FOUND",
"NO_STOPS_IN_RANGE",
"WALKING_BETTER_THAN_TRANSIT"
]),
description: Faker.Lorem.sentence(3)
}
end

def agency_factory do
%Agency{
name: Faker.Util.pick(["MBTA", "Massport", "Logan Express"])
Expand Down