From: William Pitcock Date: Fri, 4 Jan 2019 23:50:54 +0000 (+0000) Subject: rich media: disable cachex in test mode X-Git-Url: https://git.squeep.com/?a=commitdiff_plain;h=487c00d36dee1b975ffc8fca8f0a5bb5510f71a3;p=akkoma rich media: disable cachex in test mode --- diff --git a/lib/pleroma/web/rich_media/parser.ex b/lib/pleroma/web/rich_media/parser.ex index b88ed5371..3746feaf6 100644 --- a/lib/pleroma/web/rich_media/parser.ex +++ b/lib/pleroma/web/rich_media/parser.ex @@ -1,14 +1,17 @@ defmodule Pleroma.Web.RichMedia.Parser do @parsers [Pleroma.Web.RichMedia.Parsers.OGP] - def parse(url) do - Cachex.fetch!(:rich_media_cache, url, fn _ -> - {:ok, %Tesla.Env{body: html}} = Pleroma.HTTP.get(url) + if Mix.env() == :test do + def parse(url), do: parse_url(url) + else + def parse(url), + do: {:commit, Cachex.fetch!(:rich_media_cache, url, fn _ -> parse_url(url) end)} + end - result = html |> maybe_parse() |> get_parsed_data() + defp parse_url(url) do + {:ok, %Tesla.Env{body: html}} = Pleroma.HTTP.get(url) - {:commit, result} - end) + html |> maybe_parse() |> get_parsed_data() end defp maybe_parse(html) do