Skip to content

Commit

Permalink
syntax and test fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
vdegove committed Jan 18, 2024
1 parent 64c0bdd commit d5f9081
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
5 changes: 4 additions & 1 deletion apps/transport/lib/db/resource.ex
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,10 @@ defmodule DB.Resource do

if format in public_transport_formats and is_binary(schema_name) do
changeset
|> add_error(:schema_name, "Public transport formats can’t have a schema set", resource_id: get_field(changeset, :id), resource_datagouv_id: get_field(changeset, :datagouv_id))
|> add_error(:schema_name, "Public transport formats can’t have a schema set",
resource_id: get_field(changeset, :id),
resource_datagouv_id: get_field(changeset, :datagouv_id)
)
else
changeset
end
Expand Down
4 changes: 3 additions & 1 deletion apps/transport/test/db/resource_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,8 @@ defmodule DB.ResourceTest do
test "invalid resource" do
resource = %Resource{format: "GTFS", schema_name: "anything"}
assert %Ecto.Changeset{valid?: false} = changeset = Resource.changeset(resource, %{})
assert {"public transport formats can’t have schema name", []} == changeset.errors[:schema_name]

assert {"Public transport formats can’t have a schema set", [{:resource_id, nil}, {:resource_datagouv_id, nil}]} ==
changeset.errors[:schema_name]
end
end

0 comments on commit d5f9081

Please sign in to comment.