X-Git-Url: http://git.squeep.com/?a=blobdiff_plain;f=test%2Fpleroma%2Fweb%2Fadmin_api%2Fcontrollers%2Fconfig_controller_test.exs;h=578a4c914074fda7524993cc306ffc431b1359aa;hb=a2aa309496eb98625b47cfb26858e1eee3f9b0cd;hp=765a5a4b7fc35e29105a53837d14615f930affb2;hpb=e9859b68fcb9c38b2ec27a45ffe0921e8d78b5e1;p=akkoma diff --git a/test/pleroma/web/admin_api/controllers/config_controller_test.exs b/test/pleroma/web/admin_api/controllers/config_controller_test.exs index 765a5a4b7..578a4c914 100644 --- a/test/pleroma/web/admin_api/controllers/config_controller_test.exs +++ b/test/pleroma/web/admin_api/controllers/config_controller_test.exs @@ -1,14 +1,13 @@ # Pleroma: A lightweight social networking server -# Copyright © 2017-2020 Pleroma Authors +# Copyright © 2017-2021 Pleroma Authors # SPDX-License-Identifier: AGPL-3.0-only defmodule Pleroma.Web.AdminAPI.ConfigControllerTest do - use Pleroma.Web.ConnCase, async: true + use Pleroma.Web.ConnCase import ExUnit.CaptureLog import Pleroma.Factory - alias Pleroma.Config alias Pleroma.ConfigDB setup do @@ -27,12 +26,12 @@ defmodule Pleroma.Web.AdminAPI.ConfigControllerTest do setup do: clear_config(:configurable_from_database, true) test "when configuration from database is off", %{conn: conn} do - Config.put(:configurable_from_database, false) + clear_config(:configurable_from_database, false) conn = get(conn, "/api/pleroma/admin/config") assert json_response_and_validate_schema(conn, 400) == %{ - "error" => "To use this endpoint you need to enable configuration from database." + "error" => "You must enable configurable_from_database in your config file." } end @@ -162,14 +161,16 @@ defmodule Pleroma.Web.AdminAPI.ConfigControllerTest do end end - test "POST /api/pleroma/admin/config error", %{conn: conn} do + test "POST /api/pleroma/admin/config with configdb disabled", %{conn: conn} do + clear_config(:configurable_from_database, false) + conn = conn |> put_req_header("content-type", "application/json") |> post("/api/pleroma/admin/config", %{"configs" => []}) assert json_response_and_validate_schema(conn, 400) == - %{"error" => "To use this endpoint you need to enable configuration from database."} + %{"error" => "You must enable configurable_from_database in your config file."} end describe "POST /api/pleroma/admin/config" do @@ -408,8 +409,7 @@ defmodule Pleroma.Web.AdminAPI.ConfigControllerTest do end test "saving config which need pleroma reboot", %{conn: conn} do - chat = Config.get(:chat) - on_exit(fn -> Config.put(:chat, chat) end) + clear_config([:chat, :enabled], true) assert conn |> put_req_header("content-type", "application/json") @@ -454,8 +454,7 @@ defmodule Pleroma.Web.AdminAPI.ConfigControllerTest do end test "update setting which need reboot, don't change reboot flag until reboot", %{conn: conn} do - chat = Config.get(:chat) - on_exit(fn -> Config.put(:chat, chat) end) + clear_config([:chat, :enabled], true) assert conn |> put_req_header("content-type", "application/json")