Skip to content

Commit 5e0d9fe

Browse files
mk-fgprogval
authored andcommitted
Add test for connection error when fetching wellknown_url
1 parent 7a0b816 commit 5e0d9fe

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

test/format/common_test.exs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,20 @@ defmodule M51.FormatTest do
191191
"https://example.org/_matrix/media/r0/download/example.org/foo"
192192
end
193193

194+
test "Matrix link to IRC (connection error on well-known)" do
195+
MockHTTPoison
196+
|> expect(:get, 1, fn url ->
197+
assert url == "https://example.org/.well-known/matrix/client"
198+
{:error, %HTTPoison.Error{reason: :connrefused}}
199+
end)
200+
201+
# can log "failed with connection error [connrefused]" warning
202+
Logger.remove_backend(:console)
203+
assert M51.Format.matrix2irc(~s(<img src="mxc://example.org/foo" />)) ==
204+
"https://example.org/_matrix/media/r0/download/example.org/foo"
205+
Logger.add_backend(:console)
206+
end
207+
194208
test "IRC link to Matrix" do
195209
assert M51.Format.irc2matrix("foo https://example.org") ==
196210
{"foo https://example.org",

0 commit comments

Comments
 (0)