total rebase
[anni] / test / test_helper.exs
1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2022 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-only
4
5 Code.put_compiler_option(:warnings_as_errors, true)
6
7 ExUnit.configure(max_cases: System.schedulers_online())
8
9 ExUnit.start(exclude: [:federated, :erratic])
10
11 if match?({:unix, :darwin}, :os.type()) do
12   excluded = ExUnit.configuration() |> Keyword.get(:exclude, [])
13   excluded = excluded ++ [:skip_darwin]
14   ExUnit.configure(exclude: excluded)
15 end
16
17 Ecto.Adapters.SQL.Sandbox.mode(Pleroma.Repo, :manual)
18
19 Mox.defmock(Pleroma.ReverseProxy.ClientMock, for: Pleroma.ReverseProxy.Client)
20 Mox.defmock(Pleroma.GunMock, for: Pleroma.Gun)
21
22 {:ok, _} = Application.ensure_all_started(:ex_machina)
23
24 ExUnit.after_suite(fn _results ->
25   uploads = Pleroma.Config.get([Pleroma.Uploaders.Local, :uploads], "test/uploads")
26   File.rm_rf!(uploads)
27 end)
28
29 defmodule Pleroma.Test.StaticConfig do
30   @moduledoc """
31   This module provides a Config that is completely static, built at startup time from the environment. It's safe to use in testing as it will not modify any state.
32   """
33
34   @behaviour Pleroma.Config.Getting
35   @config Application.get_all_env(:pleroma)
36
37   def get(path, default \\ nil) do
38     get_in(@config, path) || default
39   end
40 end