diff options
| author | marcin mikołajczak <git@mkljczk.pl> | 2023-02-19 22:02:03 +0100 | 
|---|---|---|
| committer | marcin mikołajczak <git@mkljczk.pl> | 2023-02-19 22:02:03 +0100 | 
| commit | 92592c25c219f44ab6454762f5a5a97e800f5b1d (patch) | |
| tree | f1db48a9b222d875841c43b9c5f9b6d2c810a500 /test/mix/tasks | |
| parent | 3ed39e310939d90ddbad7bd7ffa1ebd8aca6e74c (diff) | |
| parent | 8a0162cd9694a1c5bf131fefb6e6a8d3dcb68fae (diff) | |
| download | pleroma-92592c25c219f44ab6454762f5a5a97e800f5b1d.tar.gz pleroma-92592c25c219f44ab6454762f5a5a97e800f5b1d.zip | |
Merge remote-tracking branch 'pleroma/develop' into status-notification-type
Signed-off-by: marcin mikołajczak <git@mkljczk.pl>
Diffstat (limited to 'test/mix/tasks')
| -rw-r--r-- | test/mix/tasks/pleroma/config_test.exs | 8 | ||||
| -rw-r--r-- | test/mix/tasks/pleroma/instance_test.exs | 9 | ||||
| -rw-r--r-- | test/mix/tasks/pleroma/openapi_spec_test.exs | 62 | 
3 files changed, 69 insertions, 10 deletions
| diff --git a/test/mix/tasks/pleroma/config_test.exs b/test/mix/tasks/pleroma/config_test.exs index f90ef8804..cf6d74907 100644 --- a/test/mix/tasks/pleroma/config_test.exs +++ b/test/mix/tasks/pleroma/config_test.exs @@ -49,7 +49,6 @@ defmodule Mix.Tasks.Pleroma.ConfigTest do    describe "migrate_to_db/1" do      setup do        clear_config(:configurable_from_database, true) -      clear_config([:quack, :level])      end      @tag capture_log: true @@ -72,14 +71,12 @@ defmodule Mix.Tasks.Pleroma.ConfigTest do        config1 = ConfigDB.get_by_params(%{group: ":pleroma", key: ":first_setting"})        config2 = ConfigDB.get_by_params(%{group: ":pleroma", key: ":second_setting"}) -      config3 = ConfigDB.get_by_params(%{group: ":quack", key: ":level"})        refute ConfigDB.get_by_params(%{group: ":pleroma", key: "Pleroma.Repo"})        refute ConfigDB.get_by_params(%{group: ":postgrex", key: ":json_library"})        refute ConfigDB.get_by_params(%{group: ":pleroma", key: ":database"})        assert config1.value == [key: "value", key2: [Repo]]        assert config2.value == [key: "value2", key2: ["Activity"]] -      assert config3.value == :info      end      test "config table is truncated before migration" do @@ -108,7 +105,6 @@ defmodule Mix.Tasks.Pleroma.ConfigTest do      test "settings are migrated to file and deleted from db", %{temp_file: temp_file} do        insert_config_record(:pleroma, :setting_first, key: "value", key2: ["Activity"])        insert_config_record(:pleroma, :setting_second, key: "value2", key2: [Repo]) -      insert_config_record(:quack, :level, :info)        MixTask.run(["migrate_from_db", "--env", "temp", "-d"]) @@ -117,7 +113,6 @@ defmodule Mix.Tasks.Pleroma.ConfigTest do        file = File.read!(temp_file)        assert file =~ "config :pleroma, :setting_first,"        assert file =~ "config :pleroma, :setting_second," -      assert file =~ "config :quack, :level, :info"      end      test "load a settings with large values and pass to file", %{temp_file: temp_file} do @@ -199,7 +194,6 @@ defmodule Mix.Tasks.Pleroma.ConfigTest do      setup do        insert_config_record(:pleroma, :setting_first, key: "value", key2: ["Activity"])        insert_config_record(:pleroma, :setting_second, key: "value2", key2: [Repo]) -      insert_config_record(:quack, :level, :info)        path = "test/instance_static"        file_path = Path.join(path, "temp.exported_from_db.secret.exs") @@ -215,7 +209,6 @@ defmodule Mix.Tasks.Pleroma.ConfigTest do        file = File.read!(file_path)        assert file =~ "config :pleroma, :setting_first,"        assert file =~ "config :pleroma, :setting_second," -      assert file =~ "config :quack, :level, :info"      end      test "release", %{file_path: file_path} do @@ -227,7 +220,6 @@ defmodule Mix.Tasks.Pleroma.ConfigTest do        file = File.read!(file_path)        assert file =~ "config :pleroma, :setting_first,"        assert file =~ "config :pleroma, :setting_second," -      assert file =~ "config :quack, :level, :info"      end    end diff --git a/test/mix/tasks/pleroma/instance_test.exs b/test/mix/tasks/pleroma/instance_test.exs index 249689ec6..b1c10e03c 100644 --- a/test/mix/tasks/pleroma/instance_test.exs +++ b/test/mix/tasks/pleroma/instance_test.exs @@ -67,7 +67,9 @@ defmodule Mix.Tasks.Pleroma.InstanceTest do          "test/uploads",          "--static-dir",          "./test/../test/instance/static/", -        "--strip-uploads", +        "--strip-uploads-location", +        "y", +        "--read-uploads-description",          "y",          "--dedupe-uploads",          "n", @@ -91,7 +93,10 @@ defmodule Mix.Tasks.Pleroma.InstanceTest do      assert generated_config =~ "password: \"dbpass\""      assert generated_config =~ "configurable_from_database: true"      assert generated_config =~ "http: [ip: {127, 0, 0, 1}, port: 4000]" -    assert generated_config =~ "filters: [Pleroma.Upload.Filter.Exiftool]" + +    assert generated_config =~ +             "filters: [Pleroma.Upload.Filter.Exiftool.StripLocation, Pleroma.Upload.Filter.Exiftool.ReadDescription]" +      assert File.read!(tmp_path() <> "setup.psql") == generated_setup_psql()      assert File.exists?(Path.expand("./test/instance/static/robots.txt"))    end diff --git a/test/mix/tasks/pleroma/openapi_spec_test.exs b/test/mix/tasks/pleroma/openapi_spec_test.exs new file mode 100644 index 000000000..01437187a --- /dev/null +++ b/test/mix/tasks/pleroma/openapi_spec_test.exs @@ -0,0 +1,62 @@ +# Pleroma: A lightweight social networking server +# Copyright © 2017-2022 Pleroma Authors <https://pleroma.social/> +# SPDX-License-Identifier: AGPL-3.0-only + +defmodule Mix.Tasks.Pleroma.OpenapiSpecTest do +  use Pleroma.DataCase, async: true + +  alias Mix.Tasks.Pleroma.OpenapiSpec + +  @spec_base %{ +    "paths" => %{ +      "/cofe" => %{ +        "get" => %{ +          "operationId" => "Some.operation", +          "tags" => [] +        } +      }, +      "/mew" => %{ +        "post" => %{ +          "operationId" => "Another.operation", +          "tags" => ["mew mew"] +        } +      } +    }, +    "x-tagGroups" => [ +      %{ +        "name" => "mew", +        "tags" => ["mew mew", "abc"] +      }, +      %{ +        "name" => "lol", +        "tags" => ["lol lol", "xyz"] +      } +    ] +  } + +  describe "check_specs/1" do +    test "Every operation must have a tag" do +      assert {:error, ["Some.operation (get /cofe): No tags specified"]} == +               OpenapiSpec.check_specs(@spec_base) +    end + +    test "Every tag must be in tag groups" do +      spec = +        @spec_base +        |> put_in(["paths", "/cofe", "get", "tags"], ["abc", "def", "not specified"]) + +      assert {:error, +              [ +                "Some.operation (get /cofe): Tags #{inspect(["def", "not specified"])} not available. Please add it in \"x-tagGroups\" in Pleroma.Web.ApiSpec" +              ]} == OpenapiSpec.check_specs(spec) +    end + +    test "No errors if ok" do +      spec = +        @spec_base +        |> put_in(["paths", "/cofe", "get", "tags"], ["abc", "mew mew"]) + +      assert :ok == OpenapiSpec.check_specs(spec) +    end +  end +end | 
