mirror of
https://github.com/kieraneglin/pinchflat.git
synced 2026-01-23 02:24:24 +00:00
Improve error messages when adding a non-valid source URL (#436)
This commit is contained in:
parent
6a1b7b0160
commit
108a141c65
4 changed files with 21 additions and 2 deletions
|
|
@ -147,6 +147,18 @@ defmodule Pinchflat.SourcesTest do
|
|||
assert "could not fetch source details from URL" in errors_on(changeset).original_url
|
||||
end
|
||||
|
||||
test "adds an error if the runner succeeds but the result was invalid JSON" do
|
||||
expect(YtDlpRunnerMock, :run, fn _url, _opts, _ot, _addl -> {:ok, "Not JSON"} end)
|
||||
|
||||
valid_attrs = %{
|
||||
media_profile_id: media_profile_fixture().id,
|
||||
original_url: "https://www.youtube.com/channel/abc123"
|
||||
}
|
||||
|
||||
assert {:error, %Ecto.Changeset{} = changeset} = Sources.create_source(valid_attrs)
|
||||
assert "could not fetch source details from URL" in errors_on(changeset).original_url
|
||||
end
|
||||
|
||||
test "you can specify a custom custom_name" do
|
||||
expect(YtDlpRunnerMock, :run, &channel_mock/4)
|
||||
|
||||
|
|
|
|||
|
|
@ -133,7 +133,7 @@ defmodule Pinchflat.YtDlp.MediaCollectionTest do
|
|||
test "returns an error if the output is not JSON" do
|
||||
expect(YtDlpRunnerMock, :run, fn _url, _opts, _ot, _addl_opts -> {:ok, "Not JSON"} end)
|
||||
|
||||
assert {:error, %Jason.DecodeError{}} = MediaCollection.get_source_details(@channel_url)
|
||||
assert {:error, "Error decoding JSON response"} = MediaCollection.get_source_details(@channel_url)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue