Skip to content

Commit

Permalink
Add repro for #4383
Browse files Browse the repository at this point in the history
  • Loading branch information
thbar committed Dec 17, 2024
1 parent 90e9097 commit 19a508e
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions apps/transport/test/transport/irve/irve_extractor_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -120,4 +120,34 @@ defmodule Transport.IRVE.ExtractorTest do
|> Map.delete(:url)
]
end

test "handles non-200 response" do
resources = [
orig_resource = %{
url: expected_url = "https://static.data.gouv.fr/resources/something/something.csv",
dataset_id: "the-dataset-id",
dataset_title: "the-dataset-title",
resource_id: "the-resource-id",
resource_title: "the-resource-title",
valid: true
}
]

Transport.Req.Mock
|> expect(:get!, fn _request, options ->
assert options[:url] == expected_url

%Req.Response{
status: 404,
body: "there is nothing here"
}
end)

# parsed resources must be enriched with line count & index, and url removed
assert Transport.IRVE.Extractor.download_and_parse_all(resources) == [
orig_resource
|> Map.put(:index, 0)
|> Map.delete(:url)
]
end
end

0 comments on commit 19a508e

Please sign in to comment.